Forum Discussion
Running Total solution for slicer
- 6 years ago
Ok. I played with this some more. Please try this expression. Having account in both the table and the slicer makes this a challenge.
RunningTotal = var thisdate = CALCULATE(MAX(Total[Date]), ALLSELECTED(Total[Account]))return CALCULATE(SUM(Total[Amount]), ALLEXCEPT(Total,Total[Account]), Total[Date] <= thisdate)Regards,
Pat
Hi mahoneypat
That's what I thought, so I erased that line, but get the following result (no filters applied):
Running total is weird now, and If suppose, I apply filter month "2" and no filer on account, running total should be 62, but shows 47 on last line. If i happen to also add filter Account "102", the running total now should be 12, but nope, it shows 47.
😞
Try writing a new measure that references the original measure. This one will iterate over each account and add all of the running totals together. See if that works instead. Typing on a tablet. Sorry.
New = Sumx(values(table[account]), [original measure])
If not will look more later.
Pat
- cpdanielmc216 years ago
Helper I
Thanks Pat, but still getting same result, 😞
I just returned the original formula for running total and created the new measure, but it gives same numbers
NewMeasure = SUMX(VALUES('Table'[Account]),[RunningTotal])RunningTotal =VAR thisdate =SELECTEDVALUE ( 'Table'[Date])RETURNCALCULATE (SUM ( 'Table'[Amount]),ALL('Table'),VALUES('Table'[Account]),'Table'[Date]<= thisdate)- mahoneypat6 years ago
Microsoft Employee
The reason you are seeing the weird #s is because the max date for Account 102 is less than the max for Account 101. You need to get the max date in the selected month in the variable first with this type of change.
RunningTotalAll = var thisdate = CALCULATE(MAX(Total[Date]), ALL(Total), VALUES(Total[Month]))return CALCULATE(SUM(Total[Amount]), ALL(Total), Total[Date]<= thisdate)Regards,Pat- cpdanielmc216 years ago
Helper I
Hi Pat, thanks. I think is closer.
It shows 24 for Month 1 and 62 for Month 2, (indeed correct), but not showing the "development" of 10, 20, then 24, then 39, etc up until 62.
Also, if let's say I filter Account 102, should get 12, but get 62. In this case the original measure is the correct