+ Reply to Thread
Results 1 to 8 of 8

Power query top n and bottom n rows

  1. #1
    Forum Contributor
    Join Date
    09-13-2010
    Location
    Poland
    MS-Off Ver
    365
    Posts
    204

    Power query top n and bottom n rows

    hi

    is there any way to filter columns by top N and bottom N based on values from that column?

  2. #2
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,903

    Re: Power query top n and bottom n rows

    You could sort on that field and then use the Keep rows options?
    Rory

  3. #3
    Forum Contributor
    Join Date
    09-13-2010
    Location
    Poland
    MS-Off Ver
    365
    Posts
    204

    Re: Power query top n and bottom n rows

    Quote Originally Posted by rorya View Post
    You could sort on that field and then use the Keep rows options?
    ut I need both, top and bottom n-number of rows. for example top 5 and bottom 5

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

    Re: Power query top n and bottom n rows

    You could duplicate the query - get top n in one, bottom n in the other and then append one to the other as your output.
    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.

  5. #5
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,903

    Re: Power query top n and bottom n rows

    How do you want to handle ties? In other words, if there were, say, two items with the 5th largest (or smallest) value, do you want them both returned, so you could end up with more than 10 rows for a top and bottom 5 values? Equally, if there were multiple items with the largest value, do you still want the top 5 values?

  6. #6
    Forum Contributor
    Join Date
    09-13-2010
    Location
    Poland
    MS-Off Ver
    365
    Posts
    204

    Re: Power query top n and bottom n rows

    hi,

    there are no duplicates and regarding results with the same value, would be best to have them all in - so it also can be top 10 and bottom 5.

  7. #7
    Forum Contributor
    Join Date
    09-13-2010
    Location
    Poland
    MS-Off Ver
    365
    Posts
    204

    Re: Power query top n and bottom n rows

    I am looking for a one query solution I already have multiple queries in that file and do not want it to be too messy.

  8. #8
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,903

    Re: Power query top n and bottom n rows

    Quote Originally Posted by afgi View Post
    there are no duplicates and regarding results with the same value
    ?? Duplicates are results with the same value, so which is it?

+ 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] rows to column by power query
    By siddiqsh in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-18-2020, 11:17 AM
  2. [SOLVED] Power Query - add empty rows & rows of text below bottom of group
    By josephteh in forum Excel General
    Replies: 1
    Last Post: 11-16-2020, 02:59 PM
  3. [SOLVED] Power Query - excel formula translation into Power Query
    By afgi in forum Excel Charting & Pivots
    Replies: 7
    Last Post: 02-19-2020, 03:38 AM
  4. Replies: 4
    Last Post: 02-17-2020, 06:03 AM
  5. Aggregating certain rows with power query?
    By jplank in forum Excel General
    Replies: 0
    Last Post: 01-10-2020, 11:34 AM
  6. [SOLVED] Select Rows between blank rows using Power Query
    By beaglesBuddy in forum Excel General
    Replies: 5
    Last Post: 08-17-2018, 08:30 PM
  7. Sub-Forum for Excel Power Tools (Power Query, Power Pivot & Power BI)
    By chullan88 in forum Suggestions for Improvement
    Replies: 10
    Last Post: 06-28-2018, 02:25 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