Median Not Working correctly?

mrmmickle1

Well-known Member
Joined
May 11, 2012
Messages
2,461
I was able to create this Dax Forumula with some help from a Marco Russo SQLBI blog post:

Code:
=(    MINX (
        FILTER (
            VALUES ( Data[Salary] ),
            CALCULATE (
                COUNT ( Data[Salary] ),
                CLT_Data[Salary]
                    <= EARLIER ( Data[Salary] )
            )
                > COUNT ( Data[Salary] ) / 2
        ),
        Data[Salary]
    )
        + MINX (
            FILTER (
                VALUES ( Data[Salary] ),
                CALCULATE (
                    COUNT ( Data[Salary] ),
                    Data[Salary]
                        <= EARLIER ( Data[Salary] )
                )
                    > ( COUNT ( Data[Salary] ) - 1 ) / 2
            ),
            Data[Salary]
        )


) / 2

It looks to be off by a little bit....

When I sort my 467 Salary values in Ascending Order I have

Data like this:


Excel 2010
A
23342500
23442500
23543000
Sheet1


Excel Median Function returns 42,500. DAX Formula Returns 43,000.

Shouldn't the answer be 42,500?
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Hi,
Yes as the median is the number in the middle of a set of numbers. The middle in a set of 467 is number 234.
 
Upvote 0
I realize the answer is wrong(Note: I do not have headers if that's what you were thinking). Does anyone have any input on how to correct the issue?
 
Upvote 0
I can't seem to replicate your issue in either Excel 2010 or 2016.

If I create a list of 467 numbers where the 234th is 42,500, the SQLBI formula gives me the correct Median = 42,500.

Also, is the CLT_Data[Salary] a typo on line 6 of your DAX above?

Can you post a sample workbook?
 
Upvote 0

Forum statistics

Threads
1,224,154
Messages
6,176,731
Members
452,740
Latest member
MrCY

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top