+ Reply to Thread
Results 1 to 5 of 5

Median/If Array Working - Almost...

  1. #1
    Registered User
    Join Date
    09-14-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    21

    Median/If Array Working - Almost...

    I'm trying to get a median value for certain regions. I have a Median/If Array formula that works for everything except one column. I can't figure out why it's returning a "0" since the formula works for all other columns. Please help!

    The spreadsheet is attached. The array formulas are in G2:I4 and I've highlighted in RED the cells where the formula isn't working.

    Thanks!
    Attached Files Attached Files

  2. #2
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: Median/If Array Working - Almost...

    The formula sees the blanks as 0.

    Try adding this:

    {=MEDIAN(IF((A:A=F2)*(D:D<>""),D:D,""))}

    I would also recommend not using whole column references with array formulas.

  3. #3
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    Office 365 ProPlus
    Posts
    5,883

    Re: Median/If Array Working - Almost...

    Because, there are enough blanks in D where A:A=F2. Those are evaluated to 0. So median value = 0.

    You should also add another condition where D:D<>"".

    As well, don't use entire column reference in IF logical calculation. Unlike SUMIF/COUNTIF(S) family of functions, it does not shrink down calculation range to used range and creates unnecessary overhead.

    Instead use dynamic named range.

    Ex:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Where
    lRegion: =Sheet1!$A$2:INDEX(Sheet1!$A:$A,COUNTA(Sheet1!$A:$A))
    lTurnover: =Sheet1!$D$2:INDEX(Sheet1!$D:$D,COUNTA(Sheet1!$A:$A))
    Attached Files Attached Files
    ?Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something.?
    ― Robert A. Heinlein

  4. #4
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,819

    Re: Median/If Array Working - Almost...

    My debugging steps:

    1) Use Evaluate formula tool to see what is happening in I2 (https://support.office.com/en-us/art...6-a70aa409b8a7 ). I notice that each of the "blanks" is turned into a 0 by the IF() function. MEDIAN() does not ignore the value 0 (it will ignore blanks), so the median of a group of numbers where most entries are 0 will be 0. The error is due to the IF() function making the blank entries 0.
    2) Which made me wonder if the other columns are working correctly (I don't think they are). If I use Advanced filter to fully remove the MEE group from the data set, and get the Median of each column, I get 29.5 for the median of column B, 169 for the median of column C, and 33 for the median of column D. I think all of your medians are wrong -- and they will be wrong because the IF() function inside of the MEDIAN() is changing blanks to 0 (standard spreadsheet behavior).

    Solution is to do something different with your data or your IF() function. Maybe ...IF($A:$A=$F2,IF(ISBLANK(B:B),"",B:B),"")... so that it tests for both conditions (region matches text and if entry is blank).
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  5. #5
    Registered User
    Join Date
    09-14-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    21

    Re: Median/If Array Working - Almost...

    This worked. Thank you so much.

+ 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] Median if formula not working
    By micina in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 11-07-2017, 04:04 PM
  2. Replies: 2
    Last Post: 04-26-2017, 11:28 AM
  3. Median of an Array
    By cdesantis01 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-09-2014, 01:18 AM
  4. Median of an Array
    By cdesantis01 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-08-2014, 11:59 PM
  5. [SOLVED] MEDIAN with IF function not working
    By happycynic80 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-01-2014, 05:40 PM
  6. [SOLVED] Median with IF not working?
    By chriskopf in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-08-2013, 02:59 PM
  7. Median Array with 3 if statements
    By dstogner in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-09-2012, 10:14 PM

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