cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
SteveG_91
Helper I
Helper I

Sum After Grouping

I have a table named "OBJECT" with the following structure and values

 

ProductNumberProductIdUnits
00561850
00561850
011600350
011601150
011600350
011601150
015600400

 

I'm trying to write a measure to sum the 'Units' after grouping by 'ProductNumber' and 'Product Id'.  My result should be one record per 'ProductNumber' with the sum of 'Units'.  It should look like this:

 

ProductNumberUnits
00550
011500
015400

 

I've tried various combinations of SUM, SUMX, and SUMMARIZE to no avail.

 

Thanks in advance.

1 ACCEPTED SOLUTION
Shaurya
Memorable Member
Memorable Member

Hi @SteveG_91,

 

I would start this by removing the duplicate rows first and getting this table:

 

Screenshot 2022-10-06 064312.jpg

 

The following DAX Formula can then be used to group by ProductNumber and add the Units values:

 

Result = SUMMARIZE('Table','Table'[ProductNumber],"Units",SUM('Table'[Units]))

 

Here's the result:

 

Screenshot 2022-10-06 064547.jpg

 

Works for you? Mark this post as a solution if it does!

View solution in original post

2 REPLIES 2
SteveG_91
Helper I
Helper I

Than worked Shaurya, thank you!  Should have thought of that myself.

Shaurya
Memorable Member
Memorable Member

Hi @SteveG_91,

 

I would start this by removing the duplicate rows first and getting this table:

 

Screenshot 2022-10-06 064312.jpg

 

The following DAX Formula can then be used to group by ProductNumber and add the Units values:

 

Result = SUMMARIZE('Table','Table'[ProductNumber],"Units",SUM('Table'[Units]))

 

Here's the result:

 

Screenshot 2022-10-06 064547.jpg

 

Works for you? Mark this post as a solution if it does!

Helpful resources

Announcements
Join Arun Ulag at MPPC23

Join Arun Ulag at MPPC23

Get a sneak peek into this year's Power Platform Conference Keynote.

PBI Sept Update Carousel

Power BI September 2023 Update

Take a look at the September 2023 Power BI update to learn more.

Learn Live

Learn Live: Event Series

Join Microsoft Reactor and learn from developers.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

Top Solution Authors