Forum Discussion
Calculating Cumulative Total with the most updated values
- 9 years ago
Hi, please try with this measure:
cumulative = VAR vtime = MAX ( Table1[TIME] ) RETURN CALCULATE ( SUMX ( SUMMARIZE ( Table1, Table1[REGION], Table1[TYPE], "MXamount", SELECTCOLUMNS ( TOPN ( 1, Table1, Table1[TIME] ), "AM", Table1[AMOUNT] ) ), [MXamount] ), FILTER ( ALLEXCEPT ( Table1, Table1[REGION] ), Table1[TIME] <= vtime ) )let me know if works
Victor
Lima-Peru
Thanks for your reply! I think your advise can help me to obtain the final number of products at the end of the day. But I also want to get the data throughout the day, so I can know how many products are in the store at each time point.
Actually I am not sure if power bi desktop can really deal with this situation. As I know power bi desktop is working on column level but my problem is on cell level (once encounter the repeated types of product, ignore the value use before and do calculation with the new value).
What do you think? I would appreciate any ideas!
Hi, please try with this measure:
cumulative =
VAR vtime =
MAX ( Table1[TIME] )
RETURN
CALCULATE (
SUMX (
SUMMARIZE (
Table1,
Table1[REGION],
Table1[TYPE],
"MXamount", SELECTCOLUMNS ( TOPN ( 1, Table1, Table1[TIME] ), "AM", Table1[AMOUNT] )
),
[MXamount]
),
FILTER ( ALLEXCEPT ( Table1, Table1[REGION] ), Table1[TIME] <= vtime )
)
let me know if works
Victor
Lima-Peru
- hokitkan9 years agoFrequent Visitor
It works perfectly!
Really impressed by the logic and thanks for your help!
- hymieho9 years ago
Resolver I
Yes, thanks. And now I know about SELECTCOLUMNS, and I had not seen this pattern for adding individual columns back after summarizing--I have only seen calculated columns. Great stuff!