+ Reply to Thread
Results 1 to 10 of 10

Percentile with multiple conditions from data in another sheet

  1. #1
    Registered User
    Join Date
    09-26-2019
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Mac 16.16.14
    Posts
    6

    Percentile with multiple conditions from data in another sheet

    Hi,

    I'm trying to work out the percentile of a set of data based on multiple conditions.

    I have a sheet containing over 100 rows of data and want to work out the percentile of those matching rows where a date is greater than or equal to one date and less than or equal to another.

    E.g Sheet 1 has multiple columns but the column which contains the data to use for the percentile is in column O. The date I'm using to match my conditions is in column M.

    The dates I'm comparing them against are in another sheet (Sheet 2) in cells D2 and E2.

    What I've tried so far is the following (using just the date in D2):

    Please Login or Register  to view this content.
    I'm only trying to match the first date for now, to get it right, before I try and match against multiple conditions.

    When searching for an answer, I've only found the criteria using =, rather than >=, therefore not sure if my syntax is correct?

    Thanks

  2. #2
    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,984

    Re: Percentile with multiple conditions from data in another sheet

    I'll make a mess of this, in the absence of a sample sheet, but:

    =PERCENTILE(IF(Sheet1!M2:M1000>=D2,IF(Sheet1!M2:M1000<=E2,Sheet1!O2:O1000)),0.9)

    This is an array formula. Array Formulae are a little different from ordinary formulae in that they MUST be confirmed in the FIRST CELL ONLY by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. After that, the array can be dragged down as normal, to cover the desired range.

    You will know the array is active when you see curly brackets { } - or "curly braces" for those of you in the USA, or "flower brackets" for those of you in India - appear around the outside of your formula. If you do not use CTRL+SHIFT+ENTER you will (almost always) get an error message or an incorrect answer. Press F2 on that cell and try again.

    Don't type the curly brackets yourself - it won't work...
    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

  3. #3
    Registered User
    Join Date
    09-26-2019
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Mac 16.16.14
    Posts
    6

    Re: Percentile with multiple conditions from data in another sheet

    Thanks for your reply.

    I've tried your suggestion but I'm just getting 0. However, I'm not sure the CTRL + SHIFT + ENTER command has worked. I'm on a Mac, so would that be CMD + SHIFT + ENTER? Also, which cell are you referring to? I guess the one where I've entered the formula?

    Thanks

  4. #4
    Registered User
    Join Date
    09-26-2019
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Mac 16.16.14
    Posts
    6

    Re: Percentile with multiple conditions from data in another sheet

    Quote Originally Posted by ferguson9 View Post
    Thanks for your reply.

    I've tried your suggestion but I'm just getting 0. However, I'm not sure the CTRL + SHIFT + ENTER command has worked. I'm on a Mac, so would that be CMD + SHIFT + ENTER? Also, which cell are you referring to? I guess the one where I've entered the formula?

    Thanks
    Ignore that, I've just realised my Mac does actually have a Control key.

    Does this work if any cells are blank, or do they have to be 0?

    Thanks

  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,984

    Re: Percentile with multiple conditions from data in another sheet

    I have no idea! I have never even touched a Mac, let alone used one!!

    An alternative, if your Excel version is 2010 or later (your profile is not clear!!):

    =aggregate(16,6,'Sheet 1'!O2:O1000/('Sheet 1'!M2:M1000>=D2),0.9)

    or if you wish to exclude blanks:

    =aggregate(16,6,'Sheet 1'!O2:O1000/(('Sheet 1'!M2:M1000>=D2)*('Sheet 1'!O2:O1000<>""),0.9)

    which should blanks in column O. If this isn't correct, end the guessing-game and attach a SMALL sample excel file (20 rows MAX), complete with a manually calculated expected nswer.

  6. #6
    Registered User
    Join Date
    09-26-2019
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Mac 16.16.14
    Posts
    6

    Re: Percentile with multiple conditions from data in another sheet

    Quote Originally Posted by Glenn Kennedy View Post
    I have no idea! I have never even touched a Mac, let alone used one!!

    An alternative, if your Excel version is 2010 or later (your profile is not clear!!):

    =aggregate(16,6,'Sheet 1'!O2:O1000/('Sheet 1'!M2:M1000>=D2),0.9)

    or if you wish to exclude blanks:

    =aggregate(16,6,'Sheet 1'!O2:O1000/(('Sheet 1'!M2:M1000>=D2)*('Sheet 1'!O2:O1000<>""),0.9)

    which should blanks in column O. If this isn't correct, end the guessing-game and attach a SMALL sample excel file (20 rows MAX), complete with a manually calculated expected nswer.
    Thanks for your reply.

    Unfortunately the attachment button won't work and I'm not allowed to add any links until I've posted a few more times

    Can I use
    Please Login or Register  to view this content.
    within the percentile formula, rather than the aggregate? e.g

    Please Login or Register  to view this content.
    That doesn't seem to make any difference. If not, can you please explain what the aggregate function is doing? I understand the 16, 6 part but not rest i.e why it's using an asterisk?

    Also, I'm using Microsoft Excel for Mac version 16.16.14 as part of Office 365. Volume license 2016.

    Thanks
    Last edited by ferguson9; 09-27-2019 at 05:28 AM.

  7. #7
    Registered User
    Join Date
    09-26-2019
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Mac 16.16.14
    Posts
    6

    Re: Percentile with multiple conditions from data in another sheet

    I've just done a few more tests on my example spreadsheet and I think it's working without having to specify to exclude the blank cells.

    The only problem I have now is that my results are slightly different to an online percentile calculator I'm using. I'm getting 8.6 for 90% percentile, whereas the online calculator returns 9, is that just simply rounding it up? (25%, 50% and 75% return the same values as mine).

    E.g using the following data;

    2, 2, 5, 2, 11

    I get 8.6 for 90% percentile.
    Online calculator gives 9 for 90% percentile.

    75% returns 5
    50% returns 2
    25% returns 2

  8. #8
    Forum Expert
    Join Date
    10-10-2016
    Location
    Sheffield
    MS-Off Ver
    365 and rarely 2016
    Posts
    3,210

    Re: Percentile with multiple conditions from data in another sheet

    It is an extrapolation to 90%

    75%=5
    100%=11

    90%= 5+ 15/25(6) 90% is 3/5ths of the way between 75% and 100% so 3/5ths of the difference= (11-5)*0.6 =3.6

    =5+3.6 =8.6

    You get funny results with percentiles when there are more percentiles than their are data points! splitting into 10 when you have 5 day points!


    but it is correct and the other program may be rounding errors

  9. #9
    Registered User
    Join Date
    09-26-2019
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Mac 16.16.14
    Posts
    6

    Re: Percentile with multiple conditions from data in another sheet

    Quote Originally Posted by davsth View Post
    It is an extrapolation to 90%

    75%=5
    100%=11

    90%= 5+ 15/25(6) 90% is 3/5ths of the way between 75% and 100% so 3/5ths of the difference= (11-5)*0.6 =3.6

    =5+3.6 =8.6

    You get funny results with percentiles when there are more percentiles than their are data points! splitting into 10 when you have 5 day points!


    but it is correct and the other program may be rounding errors
    I won't pretend I understand all that but I'll look into how percentiles are worked out, for sure!

    Most importantly right now is that the formula is correct, so thanks for confirming

  10. #10
    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,984

    Re: Percentile with multiple conditions from data in another sheet

    You're welcome.



    If that takes care of your original question, please select "Thread Tools" from the menu link above and mark this thread as SOLVED.

    It'd also be appreciated if you were to click the Add Reputation button at the foot of any of the posts of all members who helped you reach a solution.

+ 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. How to Determine Values of Percentile and Percentile Rank
    By rbellotti in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-30-2019, 09:57 AM
  2. Replies: 29
    Last Post: 01-01-2017, 10:25 AM
  3. Percentile function with multiple conditions
    By ranabananagirl in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 03-13-2015, 04:06 AM
  4. [SOLVED] Conditional percentile: Bug in percentíle function?
    By Duronka in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-13-2013, 08:08 AM
  5. Replies: 34
    Last Post: 09-03-2012, 02:06 AM
  6. Percentile calculation with 2 conditions
    By soakaos in forum Excel General
    Replies: 3
    Last Post: 05-06-2010, 11:19 AM
  7. Run time error '1004': Unable to get the Percentile property of the Worksheet....
    By jerseyguy1996 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-13-2009, 03:52 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