Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hello,
I am having issues calculating a moving average. I think there may be something wrong with my Date column? When I try to calculate a 7 day rolling average in a new column "RollAvg1" with the DAX code from the Quick Measure, the result is only averaging one row (one day), not the full 7 day window I want. I've tried removing the .[Date] suffix and it still did not work. It looks like the Time Intelligence is working within PowerBI because the automatic date table is generating, but the Date is greyed out.
Can you help?
Thanks!
RollAvg1 =
VAR __LAST_DATE =
LASTDATE ( Query1[Date].[Date] )
RETURN
AVERAGEX (
DATESBETWEEN (
Query1[Date].[Date],
DATEADD ( __LAST_DATE, -6, DAY ),
__LAST_DATE
),
CALCULATE ( SUM ( Query1[Values] ) )
)
@maxfefer , I typically used this kind of formula with date calendar
Rolling 7 day = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date],MAX(Sales[Sales Date]),-7,Day))
Thank you, @amitchandak. The equation you provided blank results in my column. I also tried including the .[Date] suffix and it still resulted in blank results.
Hi @maxfefer,
Try below calculated column:
RollAvg1 =
AVERAGEX (Filter('Query1',Query1[Date]<=earlier(Query1[Date])&&Query1[Date]>=earlier(Query1[Date])-6),
CALCULATE ( SUM ( Query1[Values] ) )
)
Thanks Kelly. This also didn't work since there is a circular logic error, probably from referencing Query1[Date] twice in the boolean. Is there a way to elevate this to Microsoft staff?
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
107 | |
105 | |
88 | |
74 | |
66 |
User | Count |
---|---|
126 | |
111 | |
100 | |
83 | |
71 |