+ Reply to Thread
Results 1 to 8 of 8

Find Top 3 Values in a Range Only if another Value is less than N

  1. #1
    Registered User
    Join Date
    06-11-2012
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    3

    Find Top 3 Values in a Range Only if another Value is less than N

    The concept seems simple to me, but I'm unable to get the right syntax.

    I am trying to find the top 3 values in Column C, so long as Column A is less than 6 years away and Column B is less than 100.

    I have attached a picture of the cell format I'm using because I am unable to paste a table format into this window for some silly reason.

    061112 EXCEL FORUM.jpg

    I tried this, but it didn't work:
    =LARGE(IF(A1<(NOW()+2190),C2:C5),1)
    =LARGE(IF(A1<(NOW()+2190),C2:C5),2)
    =LARGE(IF(A1<(NOW()+2190),C2:C5),3)

    (I obviously hadn't tried adding a condition for Column B because I was unable to solve the first condition of the date being less than 6 years away)

    Thanks
    mmi
    Last edited by mmi; 06-11-2012 at 02:05 PM.

  2. #2
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Find Top 3 Values in a Range Only if another Value is less than N

    Maybe

    =IF(A1<EDATE(TODAY(),72),LARGE(C2:C5,1),"")

  3. #3
    Forum Expert dilipandey's Avatar
    Join Date
    12-05-2011
    Location
    Dubai, UAE
    MS-Off Ver
    1997 - 2016
    Posts
    8,191

    Re: Find Top 3 Values in a Range Only if another Value is less than N

    Hi mmi,

    See the formula in attached file in column D and let me know if this works.. thanks.
    top 3 values.xlsx

    regards,
    DILIPandey

    <click on below 'star' if this helps>
    DILIPandey, Excel rMVP
    +919810929744 (India), +971528225509 (Dubai), [email protected]

  4. #4
    Valued Forum Contributor
    Join Date
    03-25-2004
    Location
    Boston, MA US
    Posts
    1,094

    Re: Find Top 3 Values in a Range Only if another Value is less than N

    Hi,

    Try,

    =IF(B1>100,"",LARGE(IF(AND($A1<=EDATE(A1,72),B1<100),$C$1:$C$5,""),1))

    Change the 1 to 2 or 3 where needed.
    HTH
    Steve

  5. #5
    Registered User
    Join Date
    06-11-2012
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Find Top 3 Values in a Range Only if another Value is less than N

    Thanks guys, but it's not quite what I'm looking for.

    I'm looking to return 4, 2, and 1 because they are the the only 3 values that are under 6 years and under 100.

    Steve, your formula seems to be the closest, but it returns 5 as my first value (which should be skipped since it has a date farther than 6 years away.

    Also, I'm hoping not to have this formula in every line. I just want to have 3 formulas that lookup the whole table and return the 3 highest values only. Hope this helps clarify?

  6. #6
    Registered User
    Join Date
    04-13-2012
    Location
    Leeds, UK
    MS-Off Ver
    Excel 2007
    Posts
    46

    Re: Find Top 3 Values in a Range Only if another Value is less than N

    This will only work if the dates are in ascending order, as in your example:

    Create a named range in the name manager with the following:

    =OFFSET(Sheet1!$C$1,0,0,MATCH(TODAY()+2191,Sheet1!$A$1:$A$5,1),1)

    Then wherever you want the list on the sheet:

    =LARGE(RangeName,1)
    =LARGE(RangeName,2)
    =LARGE(RangeName,3)


    ETA: you can also ignore the 'name' step and do

    =LARGE(OFFSET(Sheet1!$C$1,0,0,MATCH(TODAY()+2191,Sheet1!$A$1:$A$5,1),1),1)
    etc.
    Attached Files Attached Files
    Last edited by GazP; 06-11-2012 at 04:57 PM.

  7. #7
    Registered User
    Join Date
    06-11-2012
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Find Top 3 Values in a Range Only if another Value is less than N

    Thanks, my goal is to get it so that I don't have to sort by date, that way I can just return the 3 highest values for a much longer list.

  8. #8
    Registered User
    Join Date
    04-13-2012
    Location
    Leeds, UK
    MS-Off Ver
    Excel 2007
    Posts
    46

    Re: Find Top 3 Values in a Range Only if another Value is less than N

    A slight amendment to dilipandey's solution and I think it works, entered as array formulae (CTRL+SHIFT+ENTER)

    {=LARGE(IF(($A$1:$A$5<=(TODAY()+(6*365))*($B$1:$B$5<100)),$C$1:$C$5,0),1)}
    {=LARGE(IF(($A$1:$A$5<=(TODAY()+(6*365))*($B$1:$B$5<100)),$C$1:$C$5,0),2)}
    {=LARGE(IF(($A$1:$A$5<=(TODAY()+(6*365))*($B$1:$B$5<100)),$C$1:$C$5,0),3)}

    As of today it will return, 2, 1 and 0 as results; tomorrow (to include 11/06/2018) results will be 4, 2 and 1. Adjust the '<=(TODAY()+(6*365)' to suit.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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