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
csrapp96
Helper I
Helper I

Rolling Average Measure (with Parameter) - Trading Days Only

Hi all! 

 

First off, thank you in advance for your help. For something that seems so easy, this one defintely threw me for a whirlwind because of PBI's time intelligence.

 

I have data I need to calculate rolling averages for EXCLUDING weekends/Holidays. See below for Data Table: 

csrapp96_1-1654117910333.png

 

Next I have a date table to signify a "Working Day" where "Working Day" = 2   See below for Date Table:

csrapp96_3-1654117969534.png

Next, I have the dashboard piece of it where I am trying to get a parameter for rolling days that calculates the average of the last x number of days EXCLUDING weekends/holidays (this is where I have gone crazy trying to calculate this). Here's what it looks like:

csrapp96_4-1654118213918.png

 

The Dax for Rolling Average: 

5SMA Measure =
AVERAGEX(
DATESBETWEEN('Date Table'[Date], LASTDATE('Date Table'[Date]) - 'SMA Variable'[SMA Variable Value] +1, LASTDATE('Date Table'[Date])),
CALCULATE(SUM(Data[Data])))

I tried filtering off that "Working Day" = 2 but had no luck. 

 

Is there any way to exclude weekends/holidays for my rolling average calculation? What am I missing? 

THANK YOU SO SO MUCH!!

 

 

1 ACCEPTED SOLUTION

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

9 REPLIES 9
Ashish_Mathur
Super User
Super User

Hi,

I am not sure how much i can help but i would like to try.  Can you share the download link of your PBI file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi @Ashish_Mathur, I have rebuilt the dataset to attempt to solve this

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

wow - absolutely amazing!! thank you @Ashish_Mathur - truly impressive

You are welcome.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

hi again @Ashish_Mathur !! 

one follow-up question for your great answer - how would I display just the period where the true rolling average begins? For example, If I had a 5 day rolling average, the first 5 days would NOT display in the visual and it would start at day 6 once there is a rolling average. Same if it was a 30 day rolling average in the parameter, it would start at day 31 of data on my visual.

THANK YOU!

 

Hi,

If you have a 5 day rolling average, then the SMA should start apearing from Day 5 itself (not from Day 6).  You may download my PBI file from here.

Hope this helps.

Untitled.png 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

@Ashish_Mathur wow, you are truly incredible - I aspire to code like you someday! Wish I could give it 10 thumbs up

You are welcome.  Thank you for your kind words.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

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.