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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
Anonymous
Not applicable

Moving average

This formula only counts the days in which sales happen.  How can I rewrite the dax formula to give me the 1 month moving average which includes all days, excluding weekends and holidays, into the average?

Example: in the last month, my sales where $500 every working day except 4 days which had zero sales.  I want my formula to return something under $500, because there were 4 days with no sales yet my formula below returns $500 because it does not include the days with no sales.

 

My date table has a column "WorkingDays", which has a 1 for weekdays and a 0 for weekends and holidays.

 

Sales 1M MA = AVERAGEX( DATESINPERIOD( DateDimension[Date], LASTDATE( DateDimension[Date]), -1, MONTH ), [Total Sales] )

1 ACCEPTED SOLUTION
Anonymous
Not applicable

@Anonymous,

Please take a look at the following blog about how to calculate moving average without weekends/holidays.

http://sqlblog.com/blogs/alberto_ferrari/archive/2011/01/26/powerpivot-stocks-exchange-and-the-moving-average.aspx

Regards,
Lydia

View solution in original post

1 REPLY 1
Anonymous
Not applicable

@Anonymous,

Please take a look at the following blog about how to calculate moving average without weekends/holidays.

http://sqlblog.com/blogs/alberto_ferrari/archive/2011/01/26/powerpivot-stocks-exchange-and-the-moving-average.aspx

Regards,
Lydia

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! It's time to submit your entry.

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 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.