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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
MichaelK
Regular Visitor

HELP: MOVING AVERAGE EXCLUDING ZERO VALUES

Hi All,

 

I am working on creating a moving average but it is ignoring Zero values.

 

Please bare with me as I am new to the software and BI in general.....

 

Sooooooooooo......I am working with a data set which has multiple fields but the two that I am using are as follows:

1) 'reference number' (text field)

2) DATETIME 

 

I transformed the date time field to END OF HOUR so I can start to calculate average amounts of instructions hitting our queues per hour.

 

I then made another column (using the original date time data) and trasnformed that to DATE only (eg: 2016/10/12).

 

I used the below measure to count the distinct amount of days.

Distinct count days = DISTINCTCOUNT(Query1[DATE ])

 

Then I created a column and measure to count and then sum the reference numbers (used a column as DAX wouldn't alow me to sum a measure).

Column and measure are as follows.

COLUMN: Count REF NO = CALCULATE(COUNTROWS(Query1))    --I didn't use any where clause/filter for this as every line item has                                                                                                          to have a reference number

MEASURE: sum ref no = SUM(Query1[Count REF NO])

 

 

Then for my final step.....

The below measure was created to divide the Sum of my reference numbers by the distinct count of days.

 

CALCULATE(DIVIDE([sum ref no],[distinct count DAYS]))

 

The above measure has given me my moving average when it is plotted over my time field.

 

Everything works fine BUT it is ignoring Zero values and therefore overstating my averages.

 

For example if there were no instructions received on a day between a certain time, it will remove a day from my Distinct Count of Days.

Therefore the 0 value is not included in teh calculation of my average and my average is now larger than what it should be.

 

 

How can I calculate a moving average without Power BI ignoring Zero values?

 

Thank you!

 

1 ACCEPTED SOLUTION
BhaveshPatel
Community Champion
Community Champion

Check this out. This will help you to answer your question.

Thanks & Regards,
Bhavesh

Love the Self Service BI.
Please use the 'Mark as answer' link to mark a post that answers your question. If you find a reply helpful, please remember to give Kudos.

View solution in original post

2 REPLIES 2
JustineTennent
New Member

i used the quick measure to do the rolling average too but have the same problem..did you end up getting an easy solution?

BhaveshPatel
Community Champion
Community Champion

Check this out. This will help you to answer your question.

Thanks & Regards,
Bhavesh

Love the Self Service BI.
Please use the 'Mark as answer' link to mark a post that answers your question. If you find a reply helpful, please remember to give Kudos.

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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