Forum Discussion
Need Help with DAX Measure Please !
- 4 years ago
Hi,
Like many people described, I also want to suggest using a proper calendar table.
But, check the below picture and the attached pbix file, which I did not create a calendar table.
All measures are in the attached pbix file.
avg of last 7 days : =
VAR currentdate =
MAX ( Data[Date] )
VAR countdates =
CALCULATE (
COUNTROWS ( VALUES ( Data[Date] ) ),
FILTER ( ALL ( Data[Date] ), Data[Date] <= currentdate )
)
VAR sevendaysperiod =
DATESBETWEEN ( Data[Date], currentdate - 6, currentdate )
VAR result =
AVERAGEX ( sevendaysperiod, [Sales measure :] )
RETURN
IF ( countdates < 7, BLANK (), result )
Do I need to create a separate calendar table or the same date column will work.
Anonymous no need to create seperate calendar table, works from the same table. If you disect the measure you would know.