Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

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.

Reply
Bratone
Helper I
Helper I

Last X months rolling average but on a weekly level

Hello,

 

I am trying to create a measure which will give me the rolling average fot the past X months, but on a weekly level, not on a daily level. Why am I mentioning this is because I tried the following formula:

 

DA Prod% 1M MA=
AVERAGEX(DATESINPERIOD('cCalendar'[Date],LASTDATE(RAR[Date]),-3,MONTH), [Total Activities])
 
The problem with this is that it returns the average value on a daily basis: 
Bratone_0-1665056339792.png

So basically every value that you see in the above tabel, should be multiplied by 5 (the usual number of working days in a week).

 

Any idea how I will be able to get those values ? I know I can maybe add a *5 in the formula but that would not be sustainable for the situations where I have less than 5 working days.

 

Thank you! 

 

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Bratone , Try like

 

DA Prod% 1M MA=
calculate( AVERAGEX(values('cCalendar'[Month Year]) , [Total Activities]),DATESINPERIOD('cCalendar'[Date],LASTDATE(RAR[Date]),-3,MONTH) )

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@Bratone , Try like

 

DA Prod% 1M MA=
calculate( AVERAGEX(values('cCalendar'[Month Year]) , [Total Activities]),DATESINPERIOD('cCalendar'[Date],LASTDATE(RAR[Date]),-3,MONTH) )

Thank you so much,

 

I actually changed the part in formula from (values('cCalendar'[Month Year]) to (values('cCalendar'(Week Year]) and now it displays correctly.

 

One more question, do you know how can I exclude the values for which I don't have the data available for the past 3 months ? For example, July, and August shouldn't be there because they don't have 3 months old of historical data for which to calculate the measure. 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.