Results 1 to 2 of 2

Thread: Distinct Group by Index

  1. #1
    Neophyte lg1551's Avatar
    Join Date
    Mar 2021
    Posts
    1
    Articles
    0
    Excel Version
    365

    Distinct Group by Index



    Register for a FREE account, and/
    or Log in to avoid these ads!

    Hey all,

    I'm trying to accomplish a distinct Group-By index, by account number as pictured below and I want this to happen in the Power Query M-Code. I've done the numbered by grouping approach and it is just indexing the rows by each account. What I am looking to accomplish is depicted below. Any ideas? Trying to keep it as clean as possible without having to copy the table, remove dupes, and merge it back on itself.

    Account Account Index
    ABCD 1
    ABCD 1
    ABCD 1
    ABCD 1
    ACBD 1
    EDFHG 2
    EDFHG 2
    EDFHG 2
    EDFHG 2
    EDFHG 2
    IJKLM 3
    IJKLM 3
    IJKLM 3
    IJKLM 3
    IJKLM 3
    NOPQ 4
    NOPQ 4
    NOPQ 4
    NOPQ 4
    RSTU 5
    RSTU 5
    RSTU 5
    RSTU 5
    RSTU 5
    VWXYZ 6
    VWXYZ 6
    VWXYZ 6
    VWXYZ 6

  2. #2
    Administrator Ken Puls's Avatar
    Join Date
    Mar 2011
    Location
    Nanaimo, BC, Canada
    Posts
    2,450
    Articles
    44
    Blog Entries
    14
    Excel Version
    Excel Office 365 Insider
    Hi there, and welcome to the forum.

    The steps to do this are:
    • Select the Account column of your data -> Transform -> Group By
    • Configure the aggregation to be called "Data" and use the All Rows aggregation
    • Sort your data as needed
    • Go to Add Column -> Index -> From 1
    • Right click the new column -> Remove other columns
    • Expand the new column


    At that point you should be good to go
    Ken Puls, FCPA, FCMA, MS MVP

    Learn to Master Your Data at the Power Query Academy (the world's most comprehensive online Power Query training), with my book M is for Data Monkey, or our new Power Query Recipe cards!

    Main Site: http://www.excelguru.ca -||- Blog: http://www.excelguru.ca/blog -||- Forums: http://www.excelguru.ca/forums
    Check out the Excelguru Facebook Fan Page -||- Follow Me on Twitter

    If you've been given VBA code (a macro) for your solution, but don't know where to put it, CLICK HERE.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •