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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
HassanAshas
Helper V
Helper V

What is the difference between subtracting Averages of two values and using the AVERAGEX Function

I am calculating the Average Profit Margin for a dataset of Films that I have. 

 

There are two measures which I believe should give same results, but they are not. 

 

First Measure is as follows, 

 

 

Average Profit Margin = DIVIDE([Average Box Office (m)] - [Average Budget (m)], [Average Box Office (m)], BLANK())

 

 
where the two measures are defined as follows, 
 

 

Average Box Office (m) = AVERAGE(Films[BoxOfficeDollars]) / 1000000

Average Budget (m) = AVERAGE(Films[BudgetDollars]) / 1000000

 

 

The second Measure is as follows,

 

Average Profit Margin AverageX = AVERAGEX(Films, DIVIDE(Films[BoxOfficeDollars] - Films[BudgetDollars], Films[BoxOfficeDollars], BLANK()))

 

 

Now, they are being used in the same Filter Context (as far as I understand), but their results are far different from each other. Following is the result that I am getting, 

 HassanAshas_0-1668062060589.png

 

I fail to understand why they are giving different results. Can anybody help me out in understanding this? 

If you would like to take a look at the dataset or the Workbook, you can download the complete Workbook from here: 

https://drive.google.com/file/d/1NFBEiRtzs7BrOFGyNESPmcWrf49yD8C7/view?usp=sharing

2 REPLIES 2
amitchandak
Super User
Super User

@HassanAshas , Averagex will do line level calculation the correct way for this

 

 DIVIDE(Sum(Films[BoxOfficeDollars]) - Sum(Films[BudgetDollars]), Sum(Films[BoxOfficeDollars]))

 

refer

https://radacad.com/sum-vs-sumx-what-is-the-difference-of-the-two-dax-functions-in-power-bi

I understand the difference and I read the article as well, I still don't get it though. 

 

I understand that AVERAGEX will first calculate the difference row-by-row and then take the average of all the differences calculated. 

 

Whereas in Average function, you already have all the Averaged values and then you are taking the Difference of those. But that shouldn't cause any problem, should it? Because the filter context is still the same for both the scenarios. 

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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