+ Reply to Thread
Results 1 to 12 of 12

Extract Top N Values in Each Group

  1. #1
    Registered User
    Join Date
    12-04-2020
    Location
    Antipolo City, Rizal, Philippines
    MS-Off Ver
    Microsoft Office Excel 2019 and 2021
    Posts
    38

    Extract Top N Values in Each Group

    Good evening. Please, I need some help.

    How can I extract the Top 5 values from each group? I want to figure out who are the Top 5 states from each heat based on the number of points.
    Attached Files Attached Files

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,367

    Re: Extract Top N Values in Each Group

    Which version(s) of Excel will this need to work on? Your profile, as it stands, is not too helpful.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Registered User
    Join Date
    12-04-2020
    Location
    Antipolo City, Rizal, Philippines
    MS-Off Ver
    Microsoft Office Excel 2019 and 2021
    Posts
    38

    Re: Extract Top N Values in Each Group

    I am using Excel 2021, thank you.

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,367

    Re: Extract Top N Values in Each Group

    OK - I think this will work in 2021. In J4 copied down:

    =FILTER($B$2:$B$57,($E$2:$E$57=$I$2)*($G$2:$G$57=$I4))

    Adjust for each heat.

  5. #5
    Registered User
    Join Date
    12-04-2020
    Location
    Antipolo City, Rizal, Philippines
    MS-Off Ver
    Microsoft Office Excel 2019 and 2021
    Posts
    38

    Re: Extract Top N Values in Each Group

    There is a tie for 5th place in Heat 5. How can I fix this so it leaves with only one value? I made this formula to count how many times it occur: =COUNTIFS($E$2:$E$57,E2,$F$2:$F$57,">"&F2)+1

  6. #6
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,367

    Re: Extract Top N Values in Each Group

    What do you mean by 'only one value'? Not clear (to me).

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

    Re: Extract Top N Values in Each Group

    I believe the fix for this if you don't care about tie breaking criteria is to enter ALI's formula above as an array formula using CTRL + SHIFT + ENTER. If done so correctly this will add { } around your formula.
    This will remove the multiple entries for 5th place as it will only show the first one.
    <----- If you are happy with your solution please click on the "* Add Reputation" as a way to say thank you.

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

    Re: Extract Top N Values in Each Group

    Another option is
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    which will return 5 rows. If your data is always sorted descending on the points column, there is no need for the sort

  9. #9
    Registered User
    Join Date
    12-04-2020
    Location
    Antipolo City, Rizal, Philippines
    MS-Off Ver
    Microsoft Office Excel 2019 and 2021
    Posts
    38

    Re: Extract Top N Values in Each Group

    How can I extract the top value for each region? I made another worksheet titled "Ranking by Region" and when I try the XLOOKUP function, it returned the #VALUE! error.
    Attached Files Attached Files

  10. #10
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,367

    Re: Extract Top N Values in Each Group

    Pleae update your forum profile to include ONLY the version of Excel that you are using - thanks.

    Neither of us gave you an XLOOKUP formula ...

    A minor tweak of my formula above should give what you want - did you try it?

    =FILTER($B$2:$B$57,($E$2:$E$57=$J3)*($G$2:$G$57=1))

    You may need to enter it as an array (CSE) before copying down.
    Attached Files Attached Files

  11. #11
    Registered User
    Join Date
    12-04-2020
    Location
    Antipolo City, Rizal, Philippines
    MS-Off Ver
    Microsoft Office Excel 2019 and 2021
    Posts
    38

    Re: Extract Top N Values in Each Group

    Yes, it worked.

  12. #12
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,367

    Re: Extract Top N Values in Each Group

    Glad to have helped.

    If you have not already done so, you may not be aware that you can thank those who have helped you by clicking the small star icon (* Add Reputation) 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 all those who offered help.

    And update your forum profile as requested, please.

+ 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. Extract Group of Excel chart to PPT Slide and put a header for that group
    By alpharobot in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-23-2022, 10:33 AM
  2. Replies: 5
    Last Post: 05-29-2021, 03:04 AM
  3. [SOLVED] formula to extract and group
    By louis128 in forum Excel General
    Replies: 9
    Last Post: 01-16-2019, 02:38 PM
  4. [SOLVED] Extract data from each group
    By KingTamo in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 12-18-2018, 01:01 PM
  5. Replies: 6
    Last Post: 08-09-2016, 10:50 AM
  6. Extract data from multiple columns, group and sum up unique values
    By Alcotraz in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-05-2015, 06:54 PM
  7. Macro to extract data into different tabs for each values in column D "Group"
    By vijanand1279 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-26-2012, 03:30 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