Excel: MEDIAN Function Returns Incorrect Results

Last reviewed: November 3, 1994
Article ID: Q79238

SUMMARY

The MEDIAN function in Excel for Windows version 3.0 may return incorrect results. The error occurs when an even number of values are calculated with the MEDIAN function and the two middle values are equal. The problem does not exist in any other version of Excel.

MORE INFORMATION

The MEDIAN function returns the middle number in a range of sorted values if the range contains an odd number of values, or returns the average of the two middle values if the range contains an even number of values.

Comparing an even number of values may lead to incorrect results. If the two middle values are the same, the MEDIAN function will incorrectly calculate the average of the two values that surround the middle values. When an odd number of values are compared, the MEDIAN function returns correct values.

Step to Reproduce Problem

  1. Enter the following into a worksheet:

          A1:  1               B1:  1          C1:  1          D1:  1
          A2:  3               B2:  2          C2:  2          D2:  2
          A3:  5               B3:  5          C3:  2          D3:  3
          A4:                  B4:             C4:  10         D4:  10
          A5: =MEDIAN(A1:A4)
    
    

  2. Select cells A5:D5 and choose Fill Right from the Edit menu.

    The values returned to row 5 are as follows:

          A5:  3        B5:  2          C5:  5.5        D5:  2.5
    
       The values that should be returned into row 5 are:
    
          A5:  3        B5:  2          C5:  2          D5:  2.5
    
    

REFERENCES

"Microsoft Excel Function Reference," version 3.0, page 15


KBCategory: kbother
KBSubcategory:

Additional reference words: 3.00


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: November 3, 1994
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.