Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

How to do a sum of a column based on values of another column

I've seen several other posts similar to this, but the proposed solutions don't quite work for this.   Here's some sample data

 

divisioncounts
ABC23
12318
EVEN156
ODD86
ABC2
1230
ABC11
1232884
ABC1236
12312
EVEN7
ODD354
ABC76
1233
EVEN764
ODD3
ODD4

 

I need to add a column that has the summation of counts for each division.  Assume an infinite number of divisions,  assume any integer in the counts column, assume the data isn't sorted, and assume that there can be any number of entries for a division.   Lot's of assumptions, no?

 

  Ideally, the output would look like this

 

divisioncountsdivision totals
ABC231348
123182917
EVEN156927
ODD86447
ABC21348
12302917
ABC111348
12328842917
ABC12361348
123122917
EVEN7927
ODD354447
ABC761348
12332917
EVEN764927
ODD3447
ODD4447

 

note the repeats in the division totals column...

 

Please and thank you!!!!!!!

 

2 ACCEPTED SOLUTIONS
Whitewater100
Solution Sage
Solution Sage

Hi:

You can use this calculated column. I used "table" for table name - you would swop in your table name.

Sum of Divison = Calculate(Sum('Table'[counts]),
ALLEXCEPT('Table','Table'[division]))
Whitewater100_0-1651081909128.png

If you are satisified with reply, can you mark as solution? Thanks

View solution in original post

tamerj1
Super User
Super User

Hi @Anonymous 

you may try

SUMX (

CALCULATETABLE ( Table, ALLEXCEPT ( Table, Table[division] ) ), Table[counts] )

View solution in original post

2 REPLIES 2
tamerj1
Super User
Super User

Hi @Anonymous 

you may try

SUMX (

CALCULATETABLE ( Table, ALLEXCEPT ( Table, Table[division] ) ), Table[counts] )

Whitewater100
Solution Sage
Solution Sage

Hi:

You can use this calculated column. I used "table" for table name - you would swop in your table name.

Sum of Divison = Calculate(Sum('Table'[counts]),
ALLEXCEPT('Table','Table'[division]))
Whitewater100_0-1651081909128.png

If you are satisified with reply, can you mark as solution? Thanks

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.