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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
pulpfiction
Frequent Visitor

3 Month Moving Average that Ignores Blank Values

Hello! 

 

I need to create a table that shows a 3 month moving average that ignores Blank values. So far I have been able to create the following standard moving average measure: 

OrderLine Value 3M MAV =

VAR DateFilter =
DATESINPERIOD(
'Calendar'[DATE],
MAX('Calendar'[DATE]),
-3MONTH)

VAR OrderLineMA3 =
CALCULATE(
[OrderLine Value],
DateFilter)

RETURN
DIVIDE(OrderLineMA330)

However, it doesn't return the value I need. This is what I have:
  
2021-11-25_19h14_53.png

I need the measure to ignore previous months that have Blank Values in the "Value" field. ("Value" is also a measure.)
For example, the value for the 3 Month MAV for July 2020 should be an average of the months of July, June and February and the result should be (895 + 228 + 29) / 3 = 384 and not 86




9 REPLIES 9
v-shex-msft
Community Support
Community Support

Hi @pulpfiction,

Any update for these? Did the above suggestions help with your scenario? if that is the case, you can consider Kudo or accept the helpful suggestions to help others who faced similar requirements.

If these also don't help, please share more detailed information to help us clarify your scenario to test.

How to Get Your Question Answered Quickly 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
v-shex-msft
Community Support
Community Support

Hi @pulpfiction,

Did the above suggestions help with your scenario? if that is the case, you can consider Kudo or accept the helpful suggestions to help others who faced similar requirements.

If these also don't help, please share more detailed information to help us clarify your scenario to test.

How to Get Your Question Answered Quickly 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
Ashish_Mathur
Super User
Super User

Hi,

See if my solution here helps - Calculate rolling sum for the past week by ignoring blank cells.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hey Ashish and thank you for the solution provided! Unfortunately, I couldn't make it work for my case as I have missing dates in my dataset - there are days in my data without an orderline, therefore this day is missing. 

this looks good @Ashish_Mathur   i thought topn might be the solution and seems it is, thanks for sharing.





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




If my previous reply helped, please mark it as Answer.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
rsbin
Super User
Super User

@pulpfiction,

I understand what you are trying to do.  Don't know of an exact solution, but you have to do away with your current DatesInPeriod logic.  That only works assuming you have Values in the previous 3 months.  If one of those months is 0, then you have to go back an additional month. 

Thinking out loud, I think a virtual table where you find the last 3 non-zero Values.  Then sum these up and divide by 3.  I am by no means an expert in the syntax for this, but I hope this gives you another approach to this problem.

Hope this helps.

Hey rsbin, I will try your suggestion for a virtual table and will let you know if it worked. Thank you! 

agree, you probably need to create a table with the last 3 values that are not 0 and you will not be able to use a date function because the last 3 periods will always be the last 3 months ) 0 or >0.

 

however if you provide data in text format, it will mean that someone can use the data to work through the issue.  so post the data in text format.





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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