Forum Discussion
Trouble with rolling average
- Anonymous1 year ago
Hi Bibiano_Geraldo ,thanks for the quick reply, I'll add more.
Hi Anonymous ,
Regarding your question, I think you can create a virtual table to store the results you get in your visual. Finally, use this virtual table to find the average value you need
Something like this
Measure = VAR _table = SUMMARIZE(ALL('Table'),[ConvertedDate],"Result",[Site CTS Week]) VAR _CurrentWeek = SELECTEDVALUE('Table'[ConvertedDate]) RETURN AVERAGEX(FILTER(_table,'Table'[ConvertedDate] <= _CurrentWeek),[Result])Best Regards,
Wenbin Zhou
Unfortunatelly it doesn't work. Maybe I specify: I would like to achieve rolling weekly average as following:
-in the first week of a given year return the value of the measure [Site CTS week]
-in the second week average from the first two week of given year (62.71+44.39)/2= 53.55%
-in the third week average from the first three week of given year (62.71+44.39+64.31)/3= 57,14%
-analogously from next weeks until the end of given year.
I try to change Your measure as following, but it also dosn't work:
Great, its Commulative average, please try the following Dax:
Site CTS week rolling average =
VAR CurrentWeek = MAX(WeeklyTable[ConvertedDate])
VAR WeeksInRange =
FILTER(
ALL(WeeklyTable),
WeeklyTable[ConvertedDate] <= CurrentWeek
)
RETURN
AVERAGEX(
SUMMARIZE(WeeksInRange, WeeklyTable[ConvertedDate], "AverageCTS", [Site CTS week]),
[AverageCTS]
)- Anonymous1 year agoNot applicable
Sorry for mistake
I would like to achive something simillar, but calculate comulative avg starts from beinning af the year and finish at the last date of year. I changed Yours dax, but still doesn't work correctly
var CurrentYear = MAX(WeeklyTable[year])VAR CurrentWeek = MAX(WeeklyTable[ConvertedDate])VAR StartDate = CALCULATE(MIN(WeeklyTable[ConvertedDate]),FILTER(ALL(WeeklyTable),WeeklyTable[year] = CurrentYear))VAR WeeksInRange =FILTER(ALL(WeeklyTable),WeeklyTable[ConvertedDate] <= CurrentWeek && WeeklyTable[year] = CurrentYear)RETURNIF( CurrentWeek = StartDate,[Site CTS week],AVERAGEX(SUMMARIZE(WeeksInRange, WeeklyTable[ConvertedDate], "AverageCTS", [Site CTS week]),[AverageCTS]))