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
Anonymous
Not applicable

Median value not same as Excel

 

I am pretty new to power bi.

 

So I am trying to calculate median and have been getting difference in values when I calculate edian using excel and when I use power bi to do the same.

 

An example of my  table is as follows:

 

ClassmarksRoll No
A121
A4514
B1213
D4517
C2469
B2640
B1217
C1513
D6766

 

Now I plan at getting median by class. My formula works however there is a difference i result when I compare the same with median from excel.(again i am not talking about the total median but individual medians by class). this diffrence is only when the number of data points(in thiscase count of marks in a class) is odd. Somehow power bi take the average of thee middle and middle +1 value.

 

 

 

 

2 ACCEPTED SOLUTIONS
dax
Community Support
Community Support

Hi @Anonymous , 

I test this in my emviornment, I  get result like below

Measure = CALCULATE(MEDIAN('Table'[marks]))

689.PNG

688.PNG

The results are the same, and you could refer to https://www.mathsisfun.com/median.html  for logic.

Best Regards,
Zoe Zhi

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

dax
Community Support
Community Support

Hi @Anonymous , 

I have shown DAX in above post , you could refer to it, and below is expression to calculate median in excel

690.PNG

If you have other fields, you also could add it in below expression

 CALCULATE(MEDIAN('Table'[marks]), ALLEXCEPT('Table','Table'[Class]))

Best Regards,
Zoe Zhi

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
dax
Community Support
Community Support

Hi @Anonymous , 

I test this in my emviornment, I  get result like below

Measure = CALCULATE(MEDIAN('Table'[marks]))

689.PNG

688.PNG

The results are the same, and you could refer to https://www.mathsisfun.com/median.html  for logic.

Best Regards,
Zoe Zhi

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Could you share the dax used. I do the logic behind getting the medain ut having problems on what result my dax throws me.

dax
Community Support
Community Support

Hi @Anonymous , 

I have shown DAX in above post , you could refer to it, and below is expression to calculate median in excel

690.PNG

If you have other fields, you also could add it in below expression

 CALCULATE(MEDIAN('Table'[marks]), ALLEXCEPT('Table','Table'[Class]))

Best Regards,
Zoe Zhi

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Thanks a lot..Actually i had a flawed logic depening on how my table was build..Your small table kinda helped me understand the same ...Thanks a lot...

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.