Forum

SUMIF in POWER QUER...
 
Notifications
Clear all

SUMIF in POWER QUERY

10 Posts
4 Users
0 Reactions
248 Views
(@liovra)
Posts: 2
New Member
Topic starter
 

Please help me to get Grouped Sum of a column based on a value from another column:

 

Example:

I have 3 first columns: I need to get 4th column reflecting the sum of the2st column based on the value of 3rd column

 

Description Amount Account SumColumn
1001 150 1001 600
1001 200 1003  
1001 250 1004  
1002 67 1005  
1002 23 1002 90

 

thank you

 

Serghei

 
Posted : 23/07/2023 12:30 pm
Alan Sidman
(@alansidman)
Posts: 220
Member Moderator
 

It appears that the fourth column is the sum of second column based on the grouping of the first column.  Is the answer in the fourth column what you are looking for?  If not, show us a mocked up solution of what you expect.

 
Posted : 23/07/2023 6:08 pm
Philip Treacy
(@philipt)
Posts: 1629
Member Admin
 

Hi Serghei,

Try this in a new column

List.Sum(let _Acc = [Account] in Table.SelectRows(#"Changed Type", each [Description] = _Acc)[Amount])

See attached file.

Regards

Phil

 
Posted : 23/07/2023 9:36 pm
(@liovra)
Posts: 2
New Member
Topic starter
 

Hi Philip,

this is exactly what I need. Thank you very much indeed!

 

Alan, yes, the fourth column is the final result that I was looking for.

 

thank you both,

Serghei

 
Posted : 24/07/2023 11:35 am
Philip Treacy
(@philipt)
Posts: 1629
Member Admin
 

You're welcome.

Phil

 
Posted : 24/07/2023 7:06 pm
Alan Sidman
(@alansidman)
Posts: 220
Member Moderator
 

Phil,

I am curious as to how you would do the same as asked with out regard to the column Account and only total based upon the change in Description using Serghi's sample data.

Thanks.

Alan

 
Posted : 25/07/2023 2:19 pm
Philip Treacy
(@philipt)
Posts: 1629
Member Admin
 

Hi Alan,

So the end result would look like this?

Description Amount SumColumn
1001 150 600
1001 200 600
1001 250 600
1002 67 90
1002 23 90

 

You can use this

List.Sum(let _Desc = [Description] in Table.SelectRows(#"Changed Type", each [Description] = _Desc)[Amount])

Regards

Phil

 
Posted : 25/07/2023 7:38 pm
Alan Sidman
(@alansidman)
Posts: 220
Member Moderator
 

Phil,

That is exactly what I came up with.  I am guessing that to get them as Serghi has, we need another column filter on.  Thanks very much.  You have confirmed what I had.

 

Alan

 
Posted : 25/07/2023 9:55 pm
Philip Treacy
(@philipt)
Posts: 1629
Member Admin
 

No worries,

Phil

 
Posted : 26/07/2023 6:49 am
(@debaser)
Posts: 836
Member Moderator
 

Hi Alan,

I think you have to use the Account column as the original post only had the totals where the Account column equals the Description column, which is not quite the same as where the Description column changes from the previous row.

 
Posted : 26/07/2023 7:30 am
Share: