Forum Discussion
Running Total for different products and stores
- Sep 10, 2023
Not sure what is desired output. With
slsRT:=CALCULATE ( SUM ( 'Sales'[SLS] ), FILTER ( ALLEXCEPT ( 'Sales', 'Sales'[Product], Sales[Store] ), 'Sales'[YEARWEEK] <= MAX ( 'Sales'[YEARWEEK] ) ) )it's like
Not sure what is desired output. With
slsRT:=CALCULATE (
SUM ( 'Sales'[SLS] ),
FILTER (
ALLEXCEPT ( 'Sales', 'Sales'[Product], Sales[Store] ),
'Sales'[YEARWEEK] <= MAX ( 'Sales'[YEARWEEK] )
)
)
it's like
- stevebortySep 10, 2023Copper Contributor
SergeiBaklan That's great thank you!
There is one (hopefully) last complication: my real database includes many more columns that are product attributes (i.e. material, color) which I may use as filters when working with the Pivot, is there a way to take this into account in your formula without having to add all the columns into the ALLEXCEPT section?- SergeiBaklanSep 11, 2023Diamond Contributor
Sorry for some delay. You may use
filterRT := VAR maxW = MAX ( Sales[YEARWEEK] ) RETURN CALCULATE ( SUM ( 'Sales'[SLS] ), VALUES ( 'Sales'[Product] ), 'Sales'[YEARWEEK] <= maxW )For the sample
I added STOCK filtering into previous measure
slsRT := CALCULATE ( SUM ( 'Sales'[SLS] ), FILTER ( ALLEXCEPT ( 'Sales', 'Sales'[Product], Sales[Store], Sales[STOCK] ), 'Sales'[YEARWEEK] <= MAX ( 'Sales'[YEARWEEK] ) ) )both give the same result.
- stevebortyOct 23, 2023Copper Contributor
Hi SergeiBaklan!
Sorry for my very late reply. I've been using your slsRT method and it works perfectly. Yet, my database contains many additional attributes that I may eventually need as filters. Is there a way to change the red code
slsRT :=
CALCULATE (
SUM ( 'Sales'[SLS] ),
FILTER (
ALLEXCEPT ( 'Sales', 'Sales'[Product], Sales[Store], Sales[STOCK] ),
'Sales'[YEARWEEK] <= MAX ( 'Sales'[YEARWEEK] )
)
)in order to state something like "all the columns except the YEARWEEK". I tried to use two nested ALLEXCEPT, but it does not work.
Many thanks!