Forum Discussion
Running total negative and slow
- 6 years ago
Hi sprakash1192 ,
We need to calculate the value of the same period first, then accumulate. So we can create two measures to meet your requirement.
Measrue2 = CALCULATE( SUM('Table'[values]), SAMEPERIODLASTYEAR('Table'[Date]),ALLSELECTED('Table'))same period last year = CALCULATE([Measrue2],FILTER(ALLSELECTED('Table'),'Table'[Date]<=MAX('Table'[Date])))The result like this,
If it doesn’t meet your requirement, could you please show the exact expected result based on the table that you have shared?
BTW, pbix as attached.
Best regards,
Community Support Team _ zhenbw
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thank you Amit. That helps. My DAX query is still slow. I think it is because of the sheer amount of data.
Also, how do I calculate the running total for the same period last year and do a comparison?
Hi sprakash1192 ,
We need to calculate the value of the same period first, then accumulate. So we can create two measures to meet your requirement.
Measrue2 =
CALCULATE(
SUM('Table'[values]),
SAMEPERIODLASTYEAR('Table'[Date]),ALLSELECTED('Table'))same period last year =
CALCULATE([Measrue2],FILTER(ALLSELECTED('Table'),'Table'[Date]<=MAX('Table'[Date])))
The result like this,
If it doesn’t meet your requirement, could you please show the exact expected result based on the table that you have shared?
BTW, pbix as attached.
Best regards,
Community Support Team _ zhenbw
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.