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
gbereczk
New Member

Rolling Average not working if no margin in latest month

Hi all,

 

I'm trying to calculate 12M rolling average margin. This works fine, however when there is no margin (no revenue or cost) in the latest month, the formula ignores the month and just shows the rolling average for last month instead of adding zero margin and dividing it by +1 month. Probably this makes more sense looking at this picture:

gbereczk_0-1627728127813.png

As you can see, in Jun-21 there's no margin or average margin and the rolling average amrgin shows 607.19 rather than 539.72.

 

The DAX I used:

Average margin = AVERAGEX(VALUES('Calendar'[Date]),[Margin])
12M rolling average margin = calculate([Average margin],DATESINPERIOD('Calendar'[Date],max('Calendar'[Date]),-12,MONTH))
 
Thanks in advance!
5 REPLIES 5
v-shex-msft
Community Support
Community Support

HI @gbereczk,

In fact, it is hard to test from your snapshot. Can you please share a pbix file with some dummy data that keep the raw table data structure and expected results? They will help us clarify your scenario and test to coding formula.

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,

Share the link from where i can download your PBI file.


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

Sorry Im not able to share the full file. 

Mohammad_Refaei
Solution Specialist
Solution Specialist

Most likely the issue here is from the [Margin] formula. Please share it.

The Margin is just Revenue - Costs. The reason why Revenue is the same as Margin in the abpve example is because there are no costs for this specific customer. 

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.