+ Reply to Thread
Results 1 to 10 of 10

Looking for the INDEX of 1st and 2nd largest values of a give MONTH

  1. #1
    Registered User
    Join Date
    05-21-2014
    Location
    Saudi Arabia
    MS-Off Ver
    2021
    Posts
    38

    Question Looking for the INDEX of 1st and 2nd largest values of a give MONTH

    hi,

    I am struggling with formula to return the index of 1st largest and 2nd largest value of given month.

    I'm using this array formula to get 1st and 2nd largest values
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    and this formula to get the index of

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


    but this formula is not return correct index of 1st and 2nd largest values from given month.

    If you change month to
    JAN: its returning 1st largest value as 'product2' from column D , But it should return 'product8' which is 13 from column B i.e. JAN
    FEB: it is returning 1st largest value as 'product3 from column B i.e. JAN month, but it should return 'product5' which is 11 from column C i.e. FEB
    and so on...

    I'm attaching file for better understanding...

    Thanks!
    Attached Files Attached Files

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,946

    Re: Looking for the INDEX of 1st and 2nd largest values of a give MONTH

    Quick question - do you have repeat Names in col A in your real data?
    If not (as your data shows), then how can you get the 2nd largest?

    This will give you the largest for the given month...
    =LARGE(INDEX($B$2:$M$13,,MATCH($O$1,$B$1:$M$1,0)),1)
    and this will give the name...
    =INDEX(A2:A13,MATCH(LARGE(INDEX($B$2:$M$13,,MATCH($O$1,$B$1:$M$1,0)),1),INDEX($B$2:$M$13,,MATCH($O$1,$B$1:$M$1,0)),0))
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Registered User
    Join Date
    05-21-2014
    Location
    Saudi Arabia
    MS-Off Ver
    2021
    Posts
    38

    Re: Looking for the INDEX of 1st and 2nd largest values of a give MONTH

    Thanks FDibbins

    No, I don't have repeated Names in col A, but I also need to get the name of 2nd largest number for the given month...

  4. #4
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,946

    Re: Looking for the INDEX of 1st and 2nd largest values of a give MONTH

    OK you can adapt my suggestions to that requirement, just change the ,1 in the LARGE function to ,2

  5. #5
    Registered User
    Join Date
    05-21-2014
    Location
    Saudi Arabia
    MS-Off Ver
    2021
    Posts
    38

    Re: Looking for the INDEX of 1st and 2nd largest values of a give MONTH

    Yes, FDibbins, I did! BUT

    I'm getting same name twice because of duplicate or same number in months columns, how to handle this condition?
    Last edited by qadeerahmed; 02-26-2018 at 03:45 AM.

  6. #6
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,946

    Re: Looking for the INDEX of 1st and 2nd largest values of a give MONTH

    Ok try this...
    Largest...
    =INDEX($A$2:$A$13,MATCH(Q2,INDEX($B$2:$M$13,,MATCH($O$1,$B$1:$M$1,0)),0))
    2nd largest...
    =IF(Q2=Q3,INDEX(A:A,SMALL(IF($B$2:$B$13=Q3,ROW($A$2:$A$13)),ROWS($A$1:A2))),INDEX($A$2:$A$13,MATCH(Q3,INDEX($B$2:$M$13,,MATCH($O$1,$B$1:$M$1,0)),0)))

  7. #7
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,946

    Re: Looking for the INDEX of 1st and 2nd largest values of a give MONTH

    Note that 2nd formula needs to be ARRAY entered using CSE

  8. #8
    Registered User
    Join Date
    05-21-2014
    Location
    Saudi Arabia
    MS-Off Ver
    2021
    Posts
    38

    Re: Looking for the INDEX of 1st and 2nd largest values of a give MONTH

    Thank you FDibbins,

    BUT

    it is working only for month of JAN column, for other columns it is throwing #NUM error for 2nd largest
    Last edited by qadeerahmed; 02-26-2018 at 04:57 AM.

  9. #9
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2021
    Posts
    5,941

    Re: Looking for the INDEX of 1st and 2nd largest values of a give MONTH

    Or try this for the 2nd largest

    =IF(Q3<>0,INDEX($A:$A,SMALL(IF(INDEX($B$2:$M$13,0,MATCH($O$1,$B$1:$M$1,0))=Q3,ROW($A$2:$A$13)),COUNTIF(Q$2:Q3,Q3))),"")

    Ctrl+Shift+Enter.

  10. #10
    Registered User
    Join Date
    05-21-2014
    Location
    Saudi Arabia
    MS-Off Ver
    2021
    Posts
    38

    Re: Looking for the INDEX of 1st and 2nd largest values of a give MONTH

    YES,
    thanks Phuocam, its working as intended.

    Thank you both of you, Phuocam and FDibbins!

    Saved my day!

+ 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. Add 1 month to a date to give the EOM of following month
    By STUARTXL in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-31-2016, 03:46 AM
  2. [SOLVED] sum product of 4 largest or else give a specific statement
    By DJ_Habs in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-26-2016, 01:56 AM
  3. Formula to give week number of a month according to date of the month
    By tukae in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 06-08-2016, 11:14 PM
  4. Replies: 4
    Last Post: 04-04-2015, 04:24 AM
  5. [SOLVED] formula to give either the first day or last day of the month
    By Panfergrrl18 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-11-2013, 07:21 AM
  6. Get largest value based on month selected
    By Aland2929 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 03-14-2013, 05:45 AM

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