Forum Discussion

SteveG_91's avatar
SteveG_91
Helper I
3 years ago
Solved

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.

  • Hi SteveG_91,

     

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

     

     

    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:

     

     

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

2 Replies

  • Shaurya's avatar
    Shaurya
    Memorable Member

    Hi SteveG_91,

     

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

     

     

    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:

     

     

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

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