+ Reply to Thread
Results 1 to 9 of 9

Calculating median with several criteria

Hybrid View

  1. #1
    Registered User
    Join Date
    08-23-2020
    Location
    Adelaide, Australia
    MS-Off Ver
    2016
    Posts
    9

    Calculating median with several criteria

    Hi there,

    I am trying to calculate the median of "Starting dose" based on patient age between two procedure dates. I continually get a #NUM! error

    {=MEDIAN(IF($B:$B<=35,IF($A:$A>=1/1/2017,IF($A:$A<=31/12/2017,$C:$C))))}

    The median in the attached doc should = 237.5
    Attached Files Attached Files
    Last edited by Jatzbiscuits; 06-13-2024 at 09:08 PM.

  2. #2
    Forum Expert wk9128's Avatar
    Join Date
    08-15-2020
    Location
    China Shanghai
    MS-Off Ver
    365 V2503 and WPS V2024(12.1.0.18543)
    Posts
    3,944

    Re: Calculating median with several criteria

    Pls try this formula
    Formula: copy to clipboard
    =MEDIAN(IF((B:B<=35)*(A:A>=--"2017/1/1")*(A:A<=--"2017/12/31"),C:C))

  3. #3
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2024
    Posts
    6,177

    Re: Calculating median with several criteria

    Try this

    =MEDIAN(IF($B:$B<=35,IF($A:$A>=DATE(2017,1,1),IF($A:$A<=DATE(2017,12,31),$C:$C))))

    Or:

    =MEDIAN(IF($B:$B<=35,IF(YEAR($A:$A)=2017,$C:$C)))

  4. #4
    Registered User
    Join Date
    08-23-2020
    Location
    Adelaide, Australia
    MS-Off Ver
    2016
    Posts
    9

    Re: Calculating median with several criteria

    This worked great.
    How come though when I remove the age it does not work?

    WORKS: MEDIAN(IF($B:$B<=35,IF(YEAR($A:$A)=2017,$C:$C)))
    DOES NOT WORK: MEDIAN(IF(YEAR($A:$A)=2017,$C:$C)))

  5. #5
    Registered User
    Join Date
    08-23-2020
    Location
    Adelaide, Australia
    MS-Off Ver
    2016
    Posts
    9

    Re: Calculating median with several criteria

    This worked great.
    How come though when I remove the age it does not work?

    WORKS: MEDIAN(IF($B:$B<=35,IF(YEAR($A:$A)=2017,$C:$C)))
    DOES NOT WORK: MEDIAN(IF(YEAR($A:$A)=2017,$C:$C)))

  6. #6
    Forum Expert wk9128's Avatar
    Join Date
    08-15-2020
    Location
    China Shanghai
    MS-Off Ver
    365 V2503 and WPS V2024(12.1.0.18543)
    Posts
    3,944

    Re: Calculating median with several criteria

    Quote Originally Posted by jatzbiscuits View Post
    this worked great.
    How come though when i remove the age it does not work?

    Works: Median(if($b:$b<=35,if(year($a:$a)=2017,$c:$c)))
    does not work: Median(if(year($a:$a)=2017,$c:$c)))
    Formula: copy to clipboard
    =median(if(isnumber(a:a),(year(a:a)=2017)*c:c))

  7. #7
    Forum Expert wk9128's Avatar
    Join Date
    08-15-2020
    Location
    China Shanghai
    MS-Off Ver
    365 V2503 and WPS V2024(12.1.0.18543)
    Posts
    3,944

    Re: Calculating median with several criteria

    @Jatzbiscuits You're Welcome. Glad to help . Thank You for the feedback.


    If you finally get a solution please mark your thread as SOLVED:
    - Click Thread Tools above your first post,you will see the word PREFIX on the upper left, press the button to select [SOLVED] select "Mark your thread as Solved".
    - you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help
    was given. By doing so you can add to the reputation(s) of those who helped.

  8. #8
    Forum Expert
    Join Date
    09-25-2015
    Location
    Milan Italy
    MS-Off Ver
    office 365
    Posts
    1,998

    Re: Calculating median with several criteria

    E2=aggregate(16,6,c2:c20/(year(a2:a20)=2017)/(b2:b20<=35.1),0.5)

    with aggregate works with enter

  9. #9
    Forum Expert wk9128's Avatar
    Join Date
    08-15-2020
    Location
    China Shanghai
    MS-Off Ver
    365 V2503 and WPS V2024(12.1.0.18543)
    Posts
    3,944

    Re: Calculating median with several criteria

    Ans. Post#6
    Formula: copy to clipboard
    =aggregate(16,6,c:c/(year(a:a)=2017),0.5)

+ 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] Calculating mean, median and mode
    By Raehan in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 06-04-2020, 08:26 AM
  2. Calculating a Weighted Median
    By kaybee in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-14-2019, 06:35 AM
  3. [SOLVED] Help calculating median with multiple criteria
    By Masun in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 03-22-2015, 02:41 PM
  4. [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
  5. Excel 2007 : Calculating the median using multiple criteria
    By scubadiver007 in forum Excel General
    Replies: 4
    Last Post: 02-22-2012, 10:31 AM
  6. calculating MEDIAN with conditions, VBA
    By Lifeseeker in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-06-2012, 03:01 AM
  7. calculating median
    By smoosh1011 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 07-28-2009, 05:29 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