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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
JoRose
Frequent Visitor

Moving Average ignoring Dates without transaction

Hello DAX Community,

i have the following issue: My Datamodel has the three tables

  1. DimMeasurement -> Contains different measurement types 
  2. DimDate 
  3. FactMeasure -> Every measurement one row, one of the two measurement types from DimMeasurement

Screenshot_Datamodel.PNG

 

I want to calculate the moving average over the measured variation. The variation is measured severel times per day. On the same day different measurement types can occur, in my example scenario length and width measurements.

Usually nothing is measured on weekends. So the moving average needs to distinguish between the measurement types and it needs to ignore dates without measurement (not necessarily weekend but also a week day without measurement). I have uploaded the example datamodel to my OneDrive DAX_MovingAverage.pbix .
I hope one of you can help me out.

Thanks a lot

 

 

 

 

1 ACCEPTED SOLUTION

In your original post you said 

 

 but also a week day without measurement

 

You didn't mention holidays, or describe the overall context.  That led me to assume that you have regular workdays without data.  In such a case I would not want to ignore that fact, but rather highlight the impact.

 

Please indicate the window size and position for your moving average (for example "three days before to three days after").  Please also consider adding a workday flag to your dates table, rather than using a measure.

 

lbendlin_0-1693770348754.png

 

 

View solution in original post

5 REPLIES 5
lbendlin
Super User
Super User

 it needs to ignore dates without measurement (not necessarily weekend but also a week day without measurement)

That's a UX red flag.

 

But if you must - use one of the new Window functions. They are based on the current filter context and give you what you need "for free".

Hello Ilbedlin, 

in how far is this a UX red flag?

I need the moving average being calculated right. And as i know this means that days without transaction (in my case a measurement on a component), need to be ignored. Otherwise they drag the result of the moving average down although there were company holidays and nothing was measured.
correct me if i am wrong.

Could you, based on my file, give an example how a window function could solve that task?

In your original post you said 

 

 but also a week day without measurement

 

You didn't mention holidays, or describe the overall context.  That led me to assume that you have regular workdays without data.  In such a case I would not want to ignore that fact, but rather highlight the impact.

 

Please indicate the window size and position for your moving average (for example "three days before to three days after").  Please also consider adding a workday flag to your dates table, rather than using a measure.

 

lbendlin_0-1693770348754.png

 

 

Helo Ibendlin,

your solution works perfectly. Just changed "COUNTROWS" with "AVERAGEX" in combination with the measure "Variation".

 

Screenshot 2023-09-14 103430.png

Thanks a lot!! 

Helo Ibendlin,

thanks for your answer so far. I havent come to test it yet.

 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.