Forum Discussion
Calculate previousday total
Hi DAX gurus,
I use to below fromula to calculate previous day total(Measure).
It does not seem to like me :(.
Any help would be really appriciated.
VAR Total = SUM(Targets[Total])
6 Replies
- AnonymousNot applicable
maybe instead of "formula does not seem to like me" show expected results and outcome, it would be easier to help you.
Anyway i'm not 100% sure you can create a measure inside a var and recalculate it again in the result.Try to create a measure
TotalSum= SUM(Targets[Total])
Then a new onePreviousDayTotal =VAR DayPrevous = DATEADD(Targets[Date], -1, DAY)
VAR TotalPerviousDay=CALCULATE([TotalSum],DayPrevous)RETURNTotalPerviousDay- amaleranda
Post Patron
Hi Anonymous ,
Lesson learned. :) thanks for the reply.
I have done it that way but still not getting the result I want
Date Total PreviousdayTotal 25-09-19 5000 26-09-19 6000 5000 27-09-19 0 6000 28-09-19 9000 0 29-09-19 2500 9000 30-09-19 0 2500 Previous day total is the measure I am trying to calculate.
Thanks for your time
- Ashish_Mathur
Super User
Hi,
Create a Calendar Table and build a relationship from the Date column of your Data Table to the Date column of your Calendar Table. To your visual, drag the Date field from the Calendar Table. Write these measures
Total = SUM(Data[Value])
PreviousDayTotal = CALCULATE([Total],PREVIOUSDAY(Calendar[Date]))
Hope this helps.