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 )
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 )
Hi Sir,
Above Dax provided by you really helps, but when I am putting some filtering criteria like 07th of every month its not showing the average nos., seems like its working as sum of sales nos.
Including screenshots for your reference:
Before filtering Criteria:
After Filtering criteria:
Value of L7D is coming from the Dax provided by you which is correct before filtering criteria but after putting the filtering criteria of 07th day of every month L7D values are same as Daily Sales_HL.
Could you please help me in fixing this.
Regards
Manoj