+ Reply to Thread
Results 1 to 7 of 7

Ranking in Power Query via multiple columns

  1. #1
    Registered User
    Join Date
    01-06-2015
    Location
    Dallas, TX
    MS-Off Ver
    10
    Posts
    35

    Ranking in Power Query via multiple columns

    I'm looking to rank the top 5 highest values per company in a list preferably in power query. I have a list of companies in a column (col A of the attached) and then an amount (col B of the attached). I've already used PQ to sort the companies alphabetically and the amounts in descending order. The table is dynamic and there's no way for me know how many values will exist for Company A, B or C each time I run the report or when companies will be added over time. I'm looking to create a new table that only retains the top 5 highest values per company. Duplicate values within the company should still count up so I only have a max value of 5 rows per company.

    Once I can figure out how to rank these properly I can just filter out anything that is not a top 5 and continue on with the query. Appreciate your help.
    Attached Files Attached Files

  2. #2
    Forum Contributor
    Join Date
    08-26-2016
    Location
    UK
    MS-Off Ver
    O365
    Posts
    260

    Re: Ranking in Power Query via multiple columns

    Does the attached do it for you?
    The PQ doesn't require any sorting beforehand.
    I've ignored your C column.

    What do you want to happen if there are more than 5 similar amounts for a company's top performers? At the moment it's pretty random which 5 get included.
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    01-06-2015
    Location
    Dallas, TX
    MS-Off Ver
    10
    Posts
    35

    Re: Ranking in Power Query via multiple columns

    Thank you!

    I don't know the answer to your question at this point, I'll need to get with the report owner to determine if there's a high level of relevance for which one stays vs. which one goes. I do have several other columns in the master report one of which is days aged, he may want the oldest item to stay.

    I've never used custom functions before so this will be fun to try to plug in and see how it goes. Thanks for your help! I'll come back to this thread if I gain additional info that could be added to the function.

  4. #4
    Forum Contributor
    Join Date
    11-21-2013
    Location
    zimbabwe
    MS-Off Ver
    Excel 2003
    Posts
    124

    Re: Ranking in Power Query via multiple columns

    Try in C2:
    Please Login or Register  to view this content.

  5. #5
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,211

    Re: Ranking in Power Query via multiple columns

    Please try

    Please Login or Register  to view this content.
    Rank column can be removed if not need
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    01-06-2015
    Location
    Dallas, TX
    MS-Off Ver
    10
    Posts
    35

    Re: Ranking in Power Query via multiple columns

    Thanks Soledad, but I was looking to do this in PQ vs. formula.

  7. #7
    Registered User
    Join Date
    01-06-2015
    Location
    Dallas, TX
    MS-Off Ver
    10
    Posts
    35

    Re: Ranking in Power Query via multiple columns

    This worked perfectly and so fast! Thank you

+ 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] Transpose from columns to rows with Power Query
    By lofgren in forum Excel General
    Replies: 9
    Last Post: 06-21-2020, 10:56 AM
  2. [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
  3. Replies: 4
    Last Post: 02-17-2020, 06:03 AM
  4. [SOLVED] Power Query - update particular columns
    By afgi in forum Excel Charting & Pivots
    Replies: 10
    Last Post: 02-16-2020, 06:41 PM
  5. Custom Permutations Column in Power Query from two columns in the same Query
    By PaintPaddy in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-11-2019, 02:48 PM
  6. [SOLVED] Power Query ranking multiple columns
    By rs1aj in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-26-2019, 11:43 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