Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Group by calculated column

I have the below table, I need to create a calculated column "Overall Product and Trn  Sales",  which will be the sum of SalesAmount for the Trn ID and Product ID summarized.

Trn IDBrandLocationProduct IDSalesAmountOverall Product and Trn  Sales
1aUS15 
2bUK110 
2cCA110 
1dIN110 
3eDE110 

 

Resultant column should look like the below:

 

 

The below measure worked, 

Overall Product and Trn  Sales =
var maxdd=MAX(table[Trn ID]])

var TotalSales=
CALCULATE(
SUM(Table[SalesAmount]),
table[Trn ID]]=maxdd,
ALLEXCEPT(table,table[Product ID])
)
return
TotalSales

 

Could someone please let me know how the dax for calculated column should be?

 

 

  • Anonymous , Create a new column like

    SUMX(filter(Table, table[Trn ID] = earlier (Trn ID)), Table[SalesAmount])

1 Reply

  • Anonymous , Create a new column like

    SUMX(filter(Table, table[Trn ID] = earlier (Trn ID)), Table[SalesAmount])