cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
learn2fly
Frequent Visitor

Missing dates for 4days Moving Average

Hi I am trying to find the moving average for a data sets with missing data but I am having hard time getting an accurate averages.

I did create a date table on the power query side and merge it with my data but for some odd reasons the average is not including the missing dates.

learn2fly_2-1626339775750.png

 

This is what Power Bi is showing:

 

learn2fly_0-1626338064067.png

 

 

But when I did it in Excel, I got the correct moving 4 days average:

learn2fly_1-1626338629945.png

Please any assist or help is greatly appreciated.Thank You!

 

 

 

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@learn2fly , Try like

Rolling 4 = CALCULATE(AverageX(values('Date'[Date]),[Revenue]),DATESINPERIOD('Date'[Date ],MAX('Date'[Date ]),-4,Day))

Did I answer your question? Mark my post as a solution! Appreciate your Kudos!! !!
Dashboard of My Blogs !! Connect on Linkedin

Learn Power BI Beginners !! Advance Power BI Concepts !! Power BI For Tableau User !! Learn Power BI in Hindi !!
Proud to be a Super User!

View solution in original post

2 REPLIES 2
V-pazhen-msft
Community Support
Community Support

@learn2fly 

It work if you revenue is a column in the same table. I guess the problem is your [revenue] is a measure calculated based on the relationship between the tables. If you can just share the sample pbix, we should able to detect the issue. 

 

Paul Zheng _ Community Support Team

amitchandak
Super User
Super User

@learn2fly , Try like

Rolling 4 = CALCULATE(AverageX(values('Date'[Date]),[Revenue]),DATESINPERIOD('Date'[Date ],MAX('Date'[Date ]),-4,Day))

Did I answer your question? Mark my post as a solution! Appreciate your Kudos!! !!
Dashboard of My Blogs !! Connect on Linkedin

Learn Power BI Beginners !! Advance Power BI Concepts !! Power BI For Tableau User !! Learn Power BI in Hindi !!
Proud to be a Super User!

View solution in original post

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Power BI October Update 2021.jpg

Power BI Release

Click here to read more about the October 2021 Release!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Teds Dev Camp Oct. 2021 768x460.jpg

Power BI Dev Camp - October 28th, 2021

Mark your calendars and join us for our next Power BI Dev Camp!