0

I'm trying to calculate the running total of a count using values from the previous date, and while my previous value calculation is correct, the running total isn't working properly. Instead of doing a running total, it's giving the same values as the previous value measure.

Sample of Data:

Example of Data

Here's the DAX that I've tried using - any help would be greatly appreciated!

Normal Values: DISTINCTCOUNTNOBLANK(Item A)

Previous Value #1: CALCULATE(Normal Values, TOPN(1, FILTER(ALLSELECTED(Table), Table[Date] < MAX(Table[Date])), Table[Date], DESC))

Previous Value #2: CALCULATE(Normal Values, FILTER(ALLSELECTED(Table), Table[DateRank] = (MAX(Table[DateRank]) - 1)

Running Total Attempt #1: CALCULATE(Previous Value, FILTER(ALL(Table), Table[Date] < MAX(Table[Date]))

Running Total Attempt #2: CALCULATE(Previous Value, FILTER(ALLSELECTED(Table), Table[Date] < MAX(Table[Date]))

Running Total Attempt #3: CALCULATE(Previous Value, FILTER(ALLSELECTED(Table[Date]), ISONORAFTER(Table[Date], MAX(Table[Date]), DESC)))

Running Total Attempt #4: var PreviousDay1 = CALCULATE(Normal Values, TOPN(1, FILTER(ALLSELECTED(Table), Table[Date] < MAX(Table[Date])), Table[Date], DESC)) var RunningTotal = CALCULATE(PreviousDay1, FILTER(ALL(Table), Table[Date] < MAX(Table[Date])) return Running Total

Note: both Previous Value #1 and #2 give the same exact results and are working as expected, I just tried different calculations to see if the structure was the issue. There are also no filters placed on the workbook, so it's not an issue with filters or other charts being selected on the page.

I have also tried both Previous Value #1 and #2 in all of the four Running Total DAX calculations above, but none seem to work. That being said, if I substitute "Previous Values" for "Normal Values" in the calculations, they running total calculation works, so it appears that the issue is with the previous values DAX being nested inside of the running total DAX.

nkla145
  • 1
  • 1
  • Provide sample data and expected output in a table format [How To](https://meta.stackoverflow.com/questions/302471/how-to-put-tables-in-stack-overflow) – smpa01 Dec 13 '21 at 22:02
  • Does this answer your question? [Power BI - DAX for Rolling Sum (Running total) not working,](https://stackoverflow.com/questions/36545776/power-bi-dax-for-rolling-sum-running-total-not-working) – Max Dec 14 '21 at 14:48

0 Answers0