+ Reply to Thread
Results 1 to 9 of 9

Power Query Grouping adding index at group level and expanding puzzle

  1. #1
    Forum Contributor
    Join Date
    08-03-2021
    Location
    London
    MS-Off Ver
    365
    Posts
    610

    Power Query Grouping adding index at group level and expanding puzzle

    Hello,
    I wondered if someone might be able to explain or find of interest this;

    when grouping 'All Rows' you can then expand a single group , and In this case I wanted to add an index to make a function,
    that's fine and not anything to do with this.

    But i thought I'd add the index to each grouping in the formula bar before expanding the single group,


    Please Login or Register  to view this content.
    ,

    This what's puzzling , now when a single 'table' of the 'all rows' is expanded the entire table is expanded not jus the selected one.

    I've attached a small workbook with two examples I've tried to label each step descriptively, it's not a huge problem, just curious.


    Richard.
    Attached Files Attached Files
    Last edited by Dicken; 05-02-2022 at 10:29 AM.

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

    Re: Power Query Grouping adding index at group level and expanding puzzle

    Administrative Note:

    We would very much like to help you with your query, however you need to include code tags around your code. See your previoius thread for further instructions on how (and how NOT) to do this.

    https://www.excelforum.com/office-36...ing-today.html

    Please take a moment to add the tags. Posting code between [code]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/code] tags makes your code much easier to read and copy for testing, and it also maintains VBA formatting.

    Please see Forum Rule #2 about code tags and adjust accordingly. Click on Edit to open your post, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    (Note: this change is not optional. No help to be offered until this moderation request has been fulfilled.)
    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
    Forum Contributor
    Join Date
    08-03-2021
    Location
    London
    MS-Off Ver
    365
    Posts
    610

    Re: Power Query Grouping adding index at group level and expanding puzzle

    All done, (I hope), thanks for your help once again.

    Richard.

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

    Re: Power Query Grouping adding index at group level and expanding puzzle

    Thanks - now you know.

  5. #5
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    Office 365 ProPlus
    Posts
    5,883

    Re: Power Query Grouping adding index at group level and expanding puzzle

    Your issue is that you are using "Source" as basis of adding Index. You should rather use current table context. (i.e. use "_")
    Ex:
    Please Login or Register  to view this content.
    Edit: Added i.e. portion

    Edit2: If you wanted index added to all rows level. You must add index prior to grouping operation.

    Please Login or Register  to view this content.
    Last edited by CK76; 05-02-2022 at 10:53 AM. Reason: See edit:
    ?Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something.?
    ― Robert A. Heinlein

  6. #6
    Forum Contributor
    Join Date
    08-03-2021
    Location
    London
    MS-Off Ver
    365
    Posts
    610

    Re: Power Query Grouping adding index at group level and expanding puzzle

    No, the question is why when expanding, does it reuturn the entire table , all groups, not what I want, I just want to expand on a single
    group, if you look when you expand before adding an index to each group youi can select table a b or c but if you've added an index
    in at the group level this is not possible, the questin is why, I've attached two examples showing the difference.

    Richard.

  7. #7
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    Office 365 ProPlus
    Posts
    5,883

    Re: Power Query Grouping adding index at group level and expanding puzzle

    No, the question is why when expanding, does it reuturn the entire table
    I know. When you use "Source" as reference table when you add index. You are not actually segregating to grouped context. Each grouped table will have entire "Source" as your group context.
    Hence, you get entire table back when you expand.

    Compare your code with mine. I used "_" in each context, which adds index within group. Not to entire table context.

    Try running query with the change. You should only see 7 rows for "c" with index 1 to 7 assigned.

    Latter edit. Will return 7 rows for "c" with index 14 to 20.

  8. #8
    Forum Contributor
    Join Date
    08-03-2021
    Location
    London
    MS-Off Ver
    365
    Posts
    610

    Re: Power Query Grouping adding index at group level and expanding puzzle

    Right, that makes sense, I'll have a look into it tomorrow, I've had enough today with List.Generate.
    I'll mark it up as solved. #
    Thanks,
    Richard.

  9. #9
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    Office 365 ProPlus
    Posts
    5,883

    Re: Power Query Grouping adding index at group level and expanding puzzle

    You are welcome and thanks for the rep

+ 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. Replies: 2
    Last Post: 11-12-2021, 03:44 AM
  2. Power Query grouping of related items to find earliest datetime
    By Marbleking in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-08-2021, 03:44 AM
  3. Power query grouping - conditional to data across several columns??...
    By sunnyspirit in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 04-01-2021, 11:53 AM
  4. Data grouping in Power Query
    By hudson andrew in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-12-2020, 10:44 AM
  5. [SOLVED] Get and Transform (Power Query) - Grouping numbers into bands/buckets
    By TheNewUnion in forum Excel General
    Replies: 2
    Last Post: 03-12-2019, 05:37 AM
  6. Replies: 9
    Last Post: 11-29-2017, 01:32 PM
  7. Help with grouping in power query
    By stephme55 in forum Excel General
    Replies: 1
    Last Post: 07-26-2016, 03:09 PM

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