Forum Discussion
SriRed123
6 years agoRegular Visitor
Help with aggregation in matrix for different total value
Hi, I have table with below data, which I am trying to aggregate into a matrix Store Product Day Interim Final Store1 Prod1 Day1 10 20 Store1 Prod1 ...
Anonymous
6 years agoNot applicable
Hello SriRed123
A measure like this one shoudl do the trick:
Measure =
var _Store = SELECTEDVALUE(Data[Store])
var _Day = HASONEFILTER(Data[Day])
var _DayQty = SUMX (Data, IF(Data[Interim]>Data[Final],Data[Interim],Data[Final]))
var _TempTable =
groupby(
SUMMARIZE(
Data,
Data[Store],
Data[Day],
"DayMax", max(sum(Data[Interim]), sum(Data[Final]))
),
Data[Store],
"StoreTotal", SUMX(CURRENTGROUP(), [DayMax])
)
var _StoreQty = SUMX(FILTER(_TempTable,Data[Store] = _Store), [StoreTotal])
var result = IF(_Day, _DayQty, _StoreQty) // controls wether to show day or store total
return
result
I add a second store to check the results
I assumed that were you mention Prod1, Prod2 and Prod3 in the explanation of the Total calculation that you meant Day1, Day2, Day3.
Hope this helps,
Jan
if this is a solution for you, don't forget to mark it as such. thanks