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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

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
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.