Create Index Column By Group in Power Query

Поделиться
HTML-код
  • Опубликовано: 24 ноя 2024

Комментарии • 66

  • @BIGorilla
    @BIGorilla  Год назад

    To learn more about the syntax of Table.AddIndexColumn function, make sure to check out: powerquery.how/table-addindexcolumn/

  • @FRANKWHITE1996
    @FRANKWHITE1996 Год назад +1

    To honor this film I've called one step of my query "bi gorilla" ❤

  • @jist6953
    @jist6953 Год назад +3

    OMG, THIS, THIS, THIS...I needed THIS! Thank you. Subscribed!

  • @ДенисДементьев-т3о
    @ДенисДементьев-т3о 2 года назад +2

    Dear BI Gorilla, your way of explanation is extremely clear and understandable. Thank you very much for video.

  • @viniscera-97
    @viniscera-97 11 месяцев назад +1

    Thank you from Brazil! This solution solved my problem

  • @InventarioGintracom
    @InventarioGintracom 8 месяцев назад

    I was searching this, and i did not find any video who can explain it in spanish, thank you!

  • @MaydayAggro
    @MaydayAggro 11 месяцев назад +1

    Took me forever to ask a question of Google the right way to get this video as an answer. I need to reconcile accounts with thousands of transactions per month and sometimes dozens of repeated amounts per day. Creating an index for each amount makes the job much easier, especially since my two queries do not have any like columns other than amount.

    • @piterkub
      @piterkub 6 месяцев назад

      Same here

  • @williamarthur4801
    @williamarthur4801 2 года назад +1

    I'll Look forward to it.

  • @NSLABTUTORIAIS
    @NSLABTUTORIAIS 9 месяцев назад +1

    Thank you very much. It was what I was looking for.... Muito, muito legal!!!!!

  • @dmederos13
    @dmederos13 2 года назад

    2:35am and can't keep watching your videos🤣
    This one is super handy, I feel I'm getting closer to the solution I want to implement!

  • @williamarthur4801
    @williamarthur4801 2 года назад +2

    I enjoyed the last version as it brought up the index not showing in expand,
    I've always just removed everything after each and
    // Table.AddIndexColumn( _ , "Index", 1,1, Int64.Type) }} ) //
    which doesn't cause the problem of not showing index , it's not something I'd considered and it's good to be aware of these things. I enjoy your relaxed manner very much.

    • @BIGorilla
      @BIGorilla  2 года назад +1

      Just wow, thanks for your kind words William, I really appreciate it. These are things I've only recently learned about. After recording this video, I've delved deeper into this topic. And something I learned is how the 'type table' always allows you to indicate column types.
      From the sounds of it you seem interested in the topic, so please allow me to share my latest blogpost on this:
      gorilla.bi/power-query/creating-tables/
      You will find plenty of examples that also include the relevant syntax for defining column types. Hope that helps.
      Enjoy Power Query!
      Rick

    • @williamarthur4801
      @williamarthur4801 2 года назад +1

      @@BIGorilla Thank you , yes I am interested , it's all the small things, i.e;
      I was recently using List.Accumlate to create a running total the seed is in curly brackets and I've still not really understood why apart form it's a list thing.

    • @BIGorilla
      @BIGorilla  2 года назад

      Interesting. That's a topic I haven't delved into. It will be one of my coming blogposts, just keep an eye out :)

  • @alexrosen8762
    @alexrosen8762 2 года назад +3

    Very useful tutorial. Many use cases for example to create unique index numbers for rows in different segments.

    • @BIGorilla
      @BIGorilla  2 года назад +1

      Thanks Alex, I'm glad the video is well received. I use this trick a lot and hope it serves you as well as it does for me. 😁

  • @fajnefajne4339
    @fajnefajne4339 6 месяцев назад

    I love this comprehensive explanation. Thank you.
    I feel like in the supermarket. I have a choice and I can pick up the solution I like 😊

  • @vaigundhansridhar6745
    @vaigundhansridhar6745 3 месяца назад

    this was amazing! Just what was needed while solving a tough use case. Thank you :)

  • @FabianH-zs1go
    @FabianH-zs1go 2 года назад +1

    Great Video, exactly what I was looking for! Thanks.

  • @ThamerAffara
    @ThamerAffara 6 месяцев назад

    Thank you for this wonderful easy to follow!

  • @willvanluven2769
    @willvanluven2769 6 месяцев назад

    Awesome! True BI hero!

  • @ninokereselidze5848
    @ninokereselidze5848 7 дней назад

    Great, thank you!

  • @raulparra60
    @raulparra60 2 года назад +1

    Gracias por compartir. Como siempre muy util este tutorial. Saludos desde Bogota - Colombia

  • @matheusgameiro61
    @matheusgameiro61 Год назад

    Useful bro!
    A manager just got mass clients transfer to his wallet, then asked me for help to get an overview about his "new wallet" what they have in pipeline, lost/cancel history and the active contracts.
    I needed to create a column with the most recent 3 contacts from the account, first i ordered desc, then used index and finally filtered index = 0 or 1 or 2 (top 3)
    ;)
    tks

  • @g5scosandygoodwin
    @g5scosandygoodwin 2 месяца назад

    @BiGorilla - This is great, but it defines the index based on Column 1 and then Column 2. However, how can the Index be added based on Column 1 and Column 3 without reordering the columns. Column 1 (Color Group) and Column 3 (SalesAmount) would be a more logical indexing in your data set.

  • @adrianacorrea5634
    @adrianacorrea5634 2 года назад

    Yours videos are great. Thanks

  • @julliettecarignan8563
    @julliettecarignan8563 10 месяцев назад

    I'm curious what would be some use cases why there'd be value in having separate index sequences for the various groups? This is useful, thank you, just trying to figure out what requirement this helps us deliver (even if an intermediate one).

    • @chrismcgowan1078
      @chrismcgowan1078 10 месяцев назад

      I'm using index as primary key for a dataset (due to duplicates rows which are correct due to how the project operates). The number of rows stays the same every week but dates are updated within the dataset. I'm taking weekly copies of this dataset so that I can load them all with a date stamp column and compare week on week progress. To avoid manually adding the index column every week, grouping by date then adding the index should still create the same primary key for every row consistently each week.

  • @jafarhussain4665
    @jafarhussain4665 7 месяцев назад

    Hi @bigorilla, Thank you for this Update,
    I was creating Index based on each category but before that I Did soring based on date column so that index should be done based on the sorted date. after following your procedure, id did created Index but not based on the sorted dates., it created randomly. can you please provide some solution for this

  • @pieterlinden8292
    @pieterlinden8292 2 года назад +1

    Oh, that's super handy! It lets you do the equivalent of ROW_NUMBER() OVER (PARTITION BY...) in T-SQL, but without having to import your data into SQL Server first! Then you can do things like TOPN, but at the data source level.

  • @nancyxu4029
    @nancyxu4029 Год назад

    Great! That's super helpful. Thanks!

  • @chrisbrindle6298
    @chrisbrindle6298 2 года назад

    Excellent! Thanks man!

  • @minadev1
    @minadev1 5 месяцев назад

    I am an accounting person and wanted to learn Power BI, should I start working on M language too?

  • @arnold5621
    @arnold5621 Год назад

    Thank you so much! Exactly what I've been looking for 😍

    • @BIGorilla
      @BIGorilla  Год назад +1

      Great to hear that Arnold 🔥🙏

  • @smartwork4768
    @smartwork4768 2 года назад +1

    Nice thank you

    • @BIGorilla
      @BIGorilla  2 года назад

      You’re welcome ☺️

  • @GabrielSantos-i4x
    @GabrielSantos-i4x 6 месяцев назад

    U just saved my day! Thankssss

  • @williamarthur4801
    @williamarthur4801 2 года назад

    Re accumulate , this is slightly different to what I found online and cuts out some of the steps, add index to source, ; then insert step;
    Table.AddColumn(#"Added Index", "RTC ", each List.Accumulate (
    #"Added Index" [Units], {0} , (Step, Current ) =>

    Step & { List.Last(Step) + Current } ) {[Index]})
    I've never really got to the bottom of the ampersand, but then I could never have crated the List.Generate Febenoci sequence either, another really good video.

    • @BIGorilla
      @BIGorilla  2 года назад

      Hey William,
      The ‘step’ part is the value that changes by list accumulate. List accumulate takes the function in argument 3 and applies it for n number of times. N is the number of items in the list of argument 1.
      What the ampersand does, is it concatenates the value of ‘step’ (which is a list) to the newly transformed value in the {} list next to it.
      I’m quite on the way with the article. The written version should be out by next week :)

  • @brij26579
    @brij26579 2 года назад +1

    Awesome 👌

  • @JustMe-sh8nd
    @JustMe-sh8nd 9 месяцев назад

    gast, wauw precies wat ik nodig had, 1 tip toch, je subjects van je videos geven niet weer waar noobs op zoeken, ik zocht bijvoorbeeld op "index based on duplicate' dan kom je met deze video niet naar voren. het is dat ik geabonneerd ben en in jou lijst aan het scrollen was.

  • @martyc5674
    @martyc5674 2 года назад +1

    Very useful 👍

  • @minadev1
    @minadev1 5 месяцев назад

    i did not quite get method 02 for indexing columns after dividing by group

  • @ExcelInstructor
    @ExcelInstructor Год назад

    I stopped using the expand option long long time ago, its faster to convert the Column with Table objects to a list and then using Table.combine fonction on top of that list result of tables.

  • @alexromera6140
    @alexromera6140 9 месяцев назад

    THANKS!

  • @shivamkapoor1827
    @shivamkapoor1827 Год назад

    How can we do multiply two columns from different tables using custom function in power query??

  • @Kaushal_Khunt
    @Kaushal_Khunt 2 года назад

    Thank you Bro

  • @HudaNurhuda-c7j
    @HudaNurhuda-c7j Год назад

    In my case, I'm using a calculated table, but the issue is that calculated tables don't show up in Power Query.

  • @magnuskrook5618
    @magnuskrook5618 9 месяцев назад

    🎯 Key Takeaways for quick navigation:
    00:00 🧮 *Introduction to Adding Index Numbers in Power Query*
    - Discussing how to add index numbers to queries in Power Query for single and multiple groups.
    - An index number is a sequential number starting at 1, increasing for each item in a group.
    - Example shown with two main color groups: "other" and "popular."
    02:09 🔄 *Methods for Adding Index Numbers to Grouped Data*
    - Demonstrating different methods to add index numbers to grouped data in Power Query.
    - The first method involves using a custom column and adjusting code to reference table rows in a column.
    - Second method streamlines the process by directly adding an index column to grouped data.
    05:59 🔢 *Considerations for Data Order in Indexing*
    - Importance of sorting data correctly before grouping and indexing.
    - Demonstrates how changing the sorting order affects the index numbers assigned to different groups.
    - Example with color groups shows the impact of sorting order on index allocation.
    07:35 🆕 *Additional Method for Grouping and Indexing*
    - Introducing another method for adding index numbers to grouped data.
    - This method involves adjusting the grouping operation in Power Query.
    - Highlighting the flexibility of Power Query's 'M' language for data manipulation.
    Made with HARPA AI

  • @ansonkong3813
    @ansonkong3813 2 года назад

    I like the first method

  • @Rice0987
    @Rice0987 2 года назад

    Oh, a bit late i've saw this video, cause i forgot a case i wanted to apply this! :(
    So, i need to remember this method at least for later, may be i'll remember my case. :)
    THANKS, Rick!

    • @BIGorilla
      @BIGorilla  2 года назад

      That’s great John, if you find the case let me know!

  • @Rice0987
    @Rice0987 2 года назад

    I always have to sort rows in columns after some steps, sometimes several times to get exactly what i want.

    • @BIGorilla
      @BIGorilla  2 года назад +1

      You can sort the column before doing the group by. That should already work.
      In case it doesn’t work, you can wrap the table before the group by operation, in the Table.Buffer function. This forces the order to remain the same ☺️

  • @jaggyjut
    @jaggyjut 2 года назад

    What if we want to reset the index end of the month. I have IT helpdesk data and like to calculate the avg number of tickets per month and year

    • @BIGorilla
      @BIGorilla  2 года назад +1

      In this case it sounds easier to group your data by Month-Year, and as aggregation column create columns with:
      - Count the number of rows that's grouped.
      - All Rows - Creates a table object with the grouped rows. Unpack this object and you should be good to go.
      You will have all your data including the a line with the number of items in the month :)

  • @SamehRSameh
    @SamehRSameh 6 месяцев назад

    How can make this but categorized on 2 level
    Exambe to clarify:
    France lion 1
    France lion 2
    France paris 1
    France paris 2

  • @dirkstaszak4838
    @dirkstaszak4838 2 года назад

    I reckon number 3 is my favourite one

  • @nicolasplanchon9986
    @nicolasplanchon9986 2 года назад

    Great content! Would you know how to add an IF condition to the AddColumnIndex by any chance please ?
    Instead of iterating at every row, I would like my index to iterate only when the value of a given column changes (Source.Name in this case).
    Here is my current code :
    #"Changed Type" = Table.TransformColumnTypes(#"Filtered Rows1",{{"Source.Name", type text}, {"Team", type text}, {"Project category", type text}, {"Project type", type text}, {"Role", type text}, {"Month", type text}, {"Value", type number}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Team", "Project category", "Month"}, {{"Count", each _, type table [Source.Name=nullable text, Team=nullable text, Project category=nullable text, Project type=nullable text, Role=nullable text, Month=nullable text, Value=nullable number, Index=number]}}),
    #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Custom", each Table.AddIndexColumn([Count], "#FCST", 1, 1)),
    This is working well but I would like to pimp my #FCST column to have the kind of index I'm looking for.
    Would you have any clue about this please ?
    Thanks in advance!

    • @nicolasplanchon9986
      @nicolasplanchon9986 2 года назад

      Hi,
      I finally solved my issue with this trick :
      #"Grouped Rows" = Table.Group(#"Changed Type", {"Team", "Project category", "Month"}, {{"Count", each _, type table [Source.Name=nullable text, Team=nullable text, Project category=nullable text, Project type=nullable text, Role=nullable text, Month=nullable text, Value=nullable number, Index=number]}}),
      #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Custom", each Table.AddRankColumn([Count], "#FCST", {"Source.Name", Order.Ascending}, [RankKind = RankKind.Dense])),
      #"Expanded Custom" = Table.ExpandTableColumn(#"Added Custom", "Custom", {"Project type", "Role", "Value", "#FCST"}, {"Project type", "Role", "Value", "#FCST"}),