Reputation: 721
I need direction or exact formula help in power query. I am trying to calculate the sum of columns if condition is true, and bringing the result in new column. The code is Below;
({If [Num] = 1 Then Sum([Column1](Value),[Column3](Value)}),
If Column(Num) equlas 1 then add values in column1 and 3 If Column(Num) = 2 then add values in column2 and column3 Maybe I need to use GroupBy...
In brief what I want to do is use sumif in excel
Upvotes: 0
Views: 2635
Reputation: 60224
Based on your original question and the comments, it appears you only want to add the numbers in the same row under certain conditions of column 3 (or Num in your revised question).
Try:
=if [Column3] = 1 then [Column9] + [Column12] else null
or, in native M-Code:
#"Added Custom" = Table.AddColumn(#"Changed Type", "New Column Name", each if [Column3] = 1 then [Column9] + [Column12] else null)
Upvotes: 2