cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
ric Regular Visitor
Regular Visitor

Moving average on every day, with data which has day gaps

I have a table with several columns. One column is the date. Another column is the plant. Another column is the daily production. I want to plot the 10-day moving average of the daily production for a specific plant that the user can select, factoring in zero daily production for days when the plant did not produce. If the plant did not produce on a particular day, there is no record of production (data will not appear with zeros in my data set). I want the horizontal axis of my chart to show me all the days of the year. What is a good way to achieve this goal?

 

My attempt was to create a measure

Measure = calculate(sum(production,DATESINPERIOD(dates,LASTDATE(dates,-10,DAY))/10

 

That seems to return the correct moving average on the days when the plant produced something, but it only returns values on the days when the plant produced, whereas I want the measure to be calculated on every single day, factoring in zeros for days when there are no records of production for the plant. I have tried changing continuous/categorical x-axis but that does not fix it.

 

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Moving average on every day, with data which has day gaps

Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490


I have book! Learn Power BI from Packt


Did I answer your question? Mark my post as a solution!

Proud to be a Datanaut!

View solution in original post

1 REPLY 1
Super User
Super User

Re: Moving average on every day, with data which has day gaps

Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490


I have book! Learn Power BI from Packt


Did I answer your question? Mark my post as a solution!

Proud to be a Datanaut!

View solution in original post

Helpful resources

Announcements
Can You Solve These Challenge

Challenge: Can You Solve These?

Find out how to participate in the first Power BI 'Can You Solve These?' challenge.

New Badges

Incoming: New and Improved Badges

Exciting news: We've given our badges an overhaul and added brand news ones.

Ask Amir Anything

Exclusive LIVE Community Event No. 2 – Ask Amir Anything

Next in our Triple A series: Ask Amir Netz questions about the latest updates, features and future.

Analytics in Azure virtual event

Analytics in Azure virtual event

Experience a limitless analytics service built to ingest, prep, manage, and serve data for immediate use in Power BI.

Users Online
Currently online: 198 members 2,249 guests
Please welcome our newest community members: