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

How to calculate average of measure

Hello,

 

I am trying to calculate average value by Quarter directly in Power BI model but when I compare the result to what I got in Excel performing the same calculatioon, I see different result. I simplified a table that I used and it looks like this:

 

QuarterPriceSF$/Sf
154545121245.00
132323212115.24
223232121219.17
234344212116.19
323232121219.17
42323332327.19
445454232319.57

 

My goal is to show average $/SF by Quarter in a clustered chart in Power BI. It is easy since I have ready $/SF calculated per each line in Excel.

 

But I tried to do this calculation directly in Power BI and I got different result. 

 

I used the table from above as data soirce in Power BI and this is how I calculated Avg S/SF:

 

$/SF Avg = AVERAGEX(Sheet1,DIVIDE(SUM(Sheet1[Price]),SUM(Sheet1[SF])))

This is a table that shows Avg $/SF value by Quarter (from Excel) compared to Avg $/SF by Quarter calculated in Power BI. Does anyone know why there is a difference?

 Avg  ExcelAvg Power BI
130.126.1
217.717.3
319.219.2
413.412.4

 

Thank you.

1 ACCEPTED SOLUTION
Sean
Community Champion
Community Champion

@lazzarjovvch74

Get rid of the 2 SUM functions inside the DIVIDE just reference the columns

 

AVERAGEX.png

View solution in original post

5 REPLIES 5
Sean
Community Champion
Community Champion

@lazzarjovvch74

Get rid of the 2 SUM functions inside the DIVIDE just reference the columns

 

AVERAGEX.png

jthomson
Solution Sage
Solution Sage

Looks like Power BI is adding up the prices and SF values before dividing them to get your average, whereas Excel is doing each line individually and then taking the average of each individual line's result

It seems like that. How could I do in Power BI what Excel does with Average function? That is my goal, to do that directly in Power BI.


@lazzarjovvch74 wrote:

It seems like that. How could I do in Power BI what Excel does with Average function? That is my goal, to do that directly in Power BI.


It's probably possible by making a calculated column that divides one by the other, sticking that column into a visual and using average as an option, if that's intended behaviour - by your method, if I've got two people selling pens and one person sells 99 red pens and no blue pens, and another sells no red pens but one blue pen, and I've got a calculation that has proportion of total pens sold that are red, Power Bi would give 99% whereas your method would give 50%...

Thank you all guys for the explanantion. I'm still growing in DAX.  It works now.

 

Best

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.