+ Reply to Thread
Results 1 to 9 of 9

If statement Median calculation returning #N/A instead of median

  1. #1
    Registered User
    Join Date
    10-23-2012
    Location
    Milwaukee
    MS-Off Ver
    Excel 2010
    Posts
    15

    If statement Median calculation returning #N/A instead of median

    Hi,

    Recently, management decided we need to report a figure as a median instead of an average. Since these figures were done in a pivot table before, this poses a problem.

    So I did some googling and found that an if statement nested in a median function should be able to support the data I am going for.

    Here is my Formula:
    =MEDIAN(IF($F$2:$F$30409=I2,$G$2:$G$30409))

    Where Column F contains my look up value (For example, Column F could include EMEA, APAC, NA, etc)

    I2 currently just has "APAC" in it with no quotes.

    Column G contains a number that I need to calculate a median for based on the value in column F.

    I made sure to CSE on my forumla as this is an array, but still I cannot get Excel to return a value.

    The #N/A error usually means your lookup value is incorrect (At least when I see it using VLOOKUP). However, I can confirm APAC is present multiple times in Column F as well as in cell I2. There are no spaces after APAC in either the source or the lookup value.

    I have changed the Format of the cells from Text to General and back but this has not changed my results. In theory, this shouldn't matter, I have had no problems in the past using a text to text vlookup.

    I thought that excel possibly could not handle a median of >30k data points, however when I do just a =median($G$2:$G$30409) it returns the correct value in no time at all.

    Does anyone else have any idea what I could try to get this to work? Manually calculating median is easy in theory, but very time consuming to do with my dataset.

    Huge thanks to anyone who can help or even has suggestions for things I can try!
    Last edited by carrod65; 08-08-2016 at 05:37 PM. Reason: for clarity

  2. #2
    Forum Expert
    Join Date
    10-09-2012
    Location
    Dallas, Texas
    MS-Off Ver
    MO 2010 & 2013
    Posts
    3,049

    Re: If statement Median calculation returning #N/A instead of median

    Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.
    Please ensure you mark your thread as Solved once it is. Click here to see how.
    If a post helps, please don't forget to add to our reputation by clicking the star icon in the bottom left-hand corner of a post.

  3. #3
    Registered User
    Join Date
    10-23-2012
    Location
    Milwaukee
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: If statement Median calculation returning #N/A instead of median

    Thanks, I was hoping to avoid that as nearly every cell in the workbook contains confidential info and desensitizing the entire thing for the sake of this question may take me as long as manually calculating all the medians.

    I will still try to do this soon, but I can't right now unfortunately.

    To add to my confusion, when I create a sample workbook with made up data, the median/IF statement calculations do work for me just fine, which is infuriating and maddening simultaneously!

    Thanks for your reply Mike.

  4. #4
    Forum Expert
    Join Date
    10-09-2012
    Location
    Dallas, Texas
    MS-Off Ver
    MO 2010 & 2013
    Posts
    3,049

    Re: If statement Median calculation returning #N/A instead of median

    I wonder if you have a text or a cell that doesnt have a number in it. I would check for that.

    Throw a filter on the entire dataset and check that column for any text or any errors.

  5. #5
    Forum Expert Crooza's Avatar
    Join Date
    10-19-2013
    Location
    Hunter Valley, Australia
    MS-Off Ver
    Excel 2003 /7/10
    Posts
    2,082

    Re: If statement Median calculation returning #N/A instead of median

    I tried your formula on a small example and it works fine
    Happy with my advice? Click on the * reputation button below

  6. #6
    Registered User
    Join Date
    10-23-2012
    Location
    Milwaukee
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: If statement Median calculation returning #N/A instead of median

    Thanks, yes I know the formula works, I simply copied it from : https://www.pryor.com/blog/how-to-ca...ttable-almost/

    But cannot for the life of me figure out why the only data set I need to use this for is the only one I cannot get it to work in .

  7. #7
    Forum Expert
    Join Date
    10-09-2012
    Location
    Dallas, Texas
    MS-Off Ver
    MO 2010 & 2013
    Posts
    3,049

    Re: If statement Median calculation returning #N/A instead of median

    Copy the file.
    Take the last 10k rows and delete them, did the formula start working?
    If not take the last 10k rows of THAT and delete it. Did it start working?
    If not then delete 5k of the remaining.

    Essentially you are trying to figure out at what point DOES it start working, then keep scoping in to find the problem.
    I suspect it is a cell, like a value stored as a text or something.

  8. #8
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: If statement Median calculation returning #N/A instead of median

    Are there any #N/A errors present in either of the ranges?
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  9. #9
    Forum Expert Crooza's Avatar
    Join Date
    10-19-2013
    Location
    Hunter Valley, Australia
    MS-Off Ver
    Excel 2003 /7/10
    Posts
    2,082

    Re: If statement Median calculation returning #N/A instead of median

    Quote Originally Posted by Tony Valko View Post
    Are there any #N/A errors present in either of the ranges?
    Like Tony says maybe there is just one row of #N/A error that is disrupting this

    Try this to filter out the errors, still as a CSE array formula

    =MEDIAN(iferror(IF($F$2:$F$30409=I2,$G$2:$G$30409),FALSE))

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Using Median IF to calculate the median for a specific criteria
    By boynejs in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 10-20-2014, 01:50 AM
  2. Using Median to get the median of seconds per day per checkpoint
    By dodgerpixie in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-16-2014, 03:38 AM
  3. Median Indirect: Find median in range and bring back adjacent cells
    By Keelin in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 06-27-2014, 08:31 AM
  4. [SOLVED] Median Ifs, need to find median $ amount per deal for each year
    By xenomorph8472 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 11-13-2012, 02:01 PM
  5. Median if returning incorrect values
    By Lifeseeker in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-29-2012, 09:39 AM
  6. median if not functioning. Returning 0
    By Lifeseeker in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-15-2011, 03:08 PM
  7. Help with calculation of median
    By sssss in forum Excel General
    Replies: 8
    Last Post: 03-26-2010, 09:43 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1