+ Reply to Thread
Results 1 to 13 of 13

Non-Array MEDIAN IF Formula

  1. #1
    Valued Forum Contributor
    Join Date
    09-09-2009
    Location
    Liverpool, England
    MS-Off Ver
    W: 2021 H: 365
    Posts
    940

    Non-Array MEDIAN IF Formula

    Evening all,

    I've created a MEDIAN IF array formula, but when I try to write the non-array equivalent I'm struggling. (I'm assuming it's an AGGREGATE formula?)

    The array formula calculates the median by rate type for all cells that have been populated (they may be blank). The formula needs to extend over an expanded range to accommodate any additional rates added.

    Attached is a sample data set along with an array solution.

    Thanks in advance,

    Snook
    Attached Files Attached Files

  2. #2
    Forum Expert dosydos's Avatar
    Join Date
    12-09-2015
    Location
    Massachusetts
    MS-Off Ver
    365(PC) V:2308
    Posts
    1,472

    Re: Non-Array MEDIAN IF Formula

    how about using FILTER() function..

    in H2 and drag down:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    <----- If you are happy with your solution please click on the "* Add Reputation" as a way to say thank you.

  3. #3
    Valued Forum Contributor
    Join Date
    09-09-2009
    Location
    Liverpool, England
    MS-Off Ver
    W: 2021 H: 365
    Posts
    940

    Re: Non-Array MEDIAN IF Formula

    Hi dosydos,

    Unfortunately the FILTER function isn't an option for me as I'm using Excel 2019 (despite the Microsoft site claiming that it's in Excel 2019). I only appear to have FILTERXML. According to my account info I'm on Microsoft Office Standard 2019.

    Snook

  4. #4
    Valued Forum Contributor
    Join Date
    09-09-2009
    Location
    Liverpool, England
    MS-Off Ver
    W: 2021 H: 365
    Posts
    940

    Re: Non-Array MEDIAN IF Formula

    The most logical attempt I can come up with is:

    =AGGREGATE(12,6,IF(($B$2:$B$50=G2)*($C$2:$C$50<>0),$C$2:$C$50,1/0))

    This returns £63.50 (I have no idea how? ) when the result should be £48.

    Any thoughts where I'm going wrong?

  5. #5
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,986

    Re: Non-Array MEDIAN IF Formula

    The median component of AGGREGATE is seriously weird. I have never got it to behave itself! Here's a workaround.

    Named Range (data):
    =IFERROR(Sheet1!$C$2:$C$35/((Sheet1!$C$2:$C$35<>"")*(Sheet1!$B$2:$B$35=Sheet1!$G2)),"")

    and

    =MEDIAN(Data)
    Attached Files Attached Files
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  6. #6
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,986

    Re: Non-Array MEDIAN IF Formula

    Well... on the plus side, your effort did at least return a number. My attempts have ALWAYS given an error.

  7. #7
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,986

    Re: Non-Array MEDIAN IF Formula

    TS... when I try your AGGREGATE.... I get the #VALUE error.

  8. #8
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,986

    Re: Non-Array MEDIAN IF Formula

    THIS works (no named range):

    =AGGREGATE(16,6,$C$2:$C$35/(($B$2:$B$35=G2)*($C$2:$C$35<>"")),0.5)

  9. #9
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,078

    Re: Non-Array MEDIAN IF Formula

    The aggregate function only works with an array when the 1st argument is 14 or greater, which is why this wont work =AGGREGATE(12,6,IF(($B$2:$B$50=G2)*($C$2:$C$50<>0),$C$2:$C$50,1/0))

  10. #10
    Valued Forum Contributor
    Join Date
    09-09-2009
    Location
    Liverpool, England
    MS-Off Ver
    W: 2021 H: 365
    Posts
    940

    Re: Non-Array MEDIAN IF Formula

    Glenn with a late bid for 'most mind-blowing solution of the year'! I have no idea how you pulled that out the onion bag?!?!

    @Fluff13 - Thanks for clarifying, that makes sense. I've read the Microsoft AGGREGATE page and it insinuates that only certain functions accept arrays but it is hardly very prescriptive (or helpful). It would probably make sense for the tool tip to change based on the function number you input. Functions 1-13 still refer to it as an array.

    Thanks all, that was mashing my head.

    Snook

  11. #11
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,986

    Re: Non-Array MEDIAN IF Formula

    There >>is<< a little disagreement about it, but most folk agree that the 50th percentile is IDENTICAL to the median.

    I had simply forgotten about AGGREGATE's function 16. It happens all-too-often these days.

  12. #12
    Valued Forum Contributor
    Join Date
    09-09-2009
    Location
    Liverpool, England
    MS-Off Ver
    W: 2021 H: 365
    Posts
    940

    Re: Non-Array MEDIAN IF Formula

    I'm certainly not going to argue!

    For info - Either percentile or quartile functions (16-19) can be used to calculate the median. You'd just change the [k] argument to 2 if you were using quartile.
    Last edited by The_Snook; 12-03-2022 at 01:33 PM.

  13. #13
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,078

    Re: Non-Array MEDIAN IF Formula

    Glad to help & thanks for the feedback.

+ 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] Excel Median IF Array Formula
    By JKBR in forum Excel Formulas & Functions
    Replies: 20
    Last Post: 12-10-2020, 02:01 AM
  2. Median Array Formula ignoring Blank Data
    By branpugh in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-09-2019, 06:46 AM
  3. Replies: 2
    Last Post: 04-26-2017, 11:28 AM
  4. [SOLVED] Can Median() be put in an Array Formula?
    By MarvinP in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 02-06-2015, 07:27 PM
  5. Median of an Array
    By cdesantis01 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-08-2014, 11:59 PM
  6. [SOLVED] Median with two If statements in an array formula
    By Debbie Thomson in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 08-27-2013, 09:39 PM
  7. [SOLVED] Median IF OR array formula
    By alex_shin in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-13-2013, 09:26 PM

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