Forum Discussion
jnrezk
4 years agoHelper III
4 week rolling average
Hi, I need to be able to create a 4 week rolling average off of calendar weeks from Monday start to Sunday end. So if I opened the report on a Wed I need to make sure the calculation cuts off on ...
Anonymous
4 years agoNot applicable
Hi jnrezk ,
I created some data:
Here are the steps you can follow:
1. Create calculated column.
week = WEEKNUM('Table'[date],2)weekday = WEEKDAY('Table'[date],2)week_column =
var _lastweek=CALCULATE(MAX('Table'[week]),FILTER(ALL('Table'),YEAR('Table'[date])=YEAR(EARLIER('Table'[date]))))
return
IF([week]=_lastweek&&WEEKDAY(DATE(YEAR([date]),12,31),2)<>7,1,[week])
2. Create measure.
avg = CALCULATE(AVERAGE('Table'[value]),FILTER(ALL('Table'),'Table'[week_column]=MAX('Table'[week_column])&&YEAR('Table'[date])=YEAR(MAX('Table'[date]))))min =
var _todayweek=WEEKNUM(TODAY(),1)
return
CALCULATE(MIN('Table'[date]),FILTER(ALL('Table'),'Table'[week_column]=MAX('Table'[week_column])&&'Table'[week_column]>=_todayweek-4&&'Table'[week_column]<=_todayweek))Flag =
IF(
MAX('Table'[date])=[min],1,0)
3. Place [Flag]in Filters, set is=1, apply filter.
4. Result:
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
jnrezk
4 years agoHelper III
Anonymous this seems to be a average daily but I am looking for total weeks