Forum Discussion
Anonymous
4 years agoNot applicable
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 ID | Brand | Location | Product ID | SalesAmount | Overall Product and Trn Sales |
| 1 | a | US | 1 | 5 | |
| 2 | b | UK | 1 | 10 | |
| 2 | c | CA | 1 | 10 | |
| 1 | d | IN | 1 | 10 | |
| 3 | e | DE | 1 | 10 |
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
- amitchandakSuper User
Anonymous , Create a new column like
SUMX(filter(Table, table[Trn ID] = earlier (Trn ID)), Table[SalesAmount])