Create Index Column By Group in Power Query

  Рет қаралды 46,951

BI Gorilla

BI Gorilla

Күн бұрын

This video shows how to create an index column for each category in your table. Within each category the number then starts from 1 and increases sequentially up to the number of items in your category.
Master Functions and Syntax in M
powerquery.how
ABOUT BI Gorilla:
BI Gorilla shares videos and articles on Power BI and Excel to help you improve your skills.
Website: gorilla.bi
SUBSCRIBE TO MY CHANNEL
kzfaq.info?sub_con...
LET'S CONNECT:
Blog: gorilla.bi
Facebook: / bigorilla
Twitter: / rickmaurinus
LinkedIn: / rickmaurinus
Thank you for your support!
00:00 Introduction
00:26 Add Regular Index
01:02 Method 1: Separate Column
03:15 Method 2: Adjust Group By - Lose Data Type
07:28 Method 3: Adjust Group By - Define Data Type
#index #powerquery #bigorilla

Пікірлер: 63
@BIGorilla
@BIGorilla 9 ай бұрын
To learn more about the syntax of Table.AddIndexColumn function, make sure to check out: powerquery.how/table-addindexcolumn/
@FRANKWHITE1996
@FRANKWHITE1996 Жыл бұрын
To honor this film I've called one step of my query "bi gorilla" ❤
@user-qi9bl9hd9l
@user-qi9bl9hd9l Жыл бұрын
Dear BI Gorilla, your way of explanation is extremely clear and understandable. Thank you very much for video.
@ericrobbins6953
@ericrobbins6953 Жыл бұрын
OMG, THIS, THIS, THIS...I needed THIS! Thank you. Subscribed!
@dmederos13
@dmederos13 Жыл бұрын
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!
@viniciuscg12ba
@viniciuscg12ba 7 ай бұрын
Thank you from Brazil! This solution solved my problem
@FabianH-zs1go
@FabianH-zs1go Жыл бұрын
Great Video, exactly what I was looking for! Thanks.
@fajnefajne4339
@fajnefajne4339 2 ай бұрын
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 😊
@ThamerAffara
@ThamerAffara 2 ай бұрын
Thank you for this wonderful easy to follow!
@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
@williamarthur4801
@williamarthur4801 2 жыл бұрын
I'll Look forward to it.
@adrianacorrea5634
@adrianacorrea5634 Жыл бұрын
Yours videos are great. Thanks
@arnold5621
@arnold5621 Жыл бұрын
Thank you so much! Exactly what I've been looking for 😍
@BIGorilla
@BIGorilla Жыл бұрын
Great to hear that Arnold 🔥🙏
@user-qb1fh2yt6h
@user-qb1fh2yt6h 2 ай бұрын
U just saved my day! Thankssss
@pieterlinden8292
@pieterlinden8292 Жыл бұрын
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.
@chrisbrindle6298
@chrisbrindle6298 Жыл бұрын
Excellent! Thanks man!
@alexrosen8762
@alexrosen8762 2 жыл бұрын
Very useful tutorial. Many use cases for example to create unique index numbers for rows in different segments.
@BIGorilla
@BIGorilla 2 жыл бұрын
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. 😁
@raulparra60
@raulparra60 2 жыл бұрын
Gracias por compartir. Como siempre muy util este tutorial. Saludos desde Bogota - Colombia
@BIGorilla
@BIGorilla 2 жыл бұрын
Mi placer!
@nancyxu4029
@nancyxu4029 8 ай бұрын
Great! That's super helpful. Thanks!
@willvanluven2769
@willvanluven2769 2 ай бұрын
Awesome! True BI hero!
@NSLABTUTORIAIS
@NSLABTUTORIAIS 5 ай бұрын
Thank you very much. It was what I was looking for.... Muito, muito legal!!!!!
@user-xs3ls5pk1t
@user-xs3ls5pk1t 4 ай бұрын
I was searching this, and i did not find any video who can explain it in spanish, thank you!
@JustMe-sh8nd
@JustMe-sh8nd 5 ай бұрын
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.
@MaydayAggro
@MaydayAggro 7 ай бұрын
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 2 ай бұрын
Same here
@alexromera6140
@alexromera6140 5 ай бұрын
THANKS!
@Kaushal_Khunt
@Kaushal_Khunt 2 жыл бұрын
Thank you Bro
@smartwork4768
@smartwork4768 2 жыл бұрын
Nice thank you
@BIGorilla
@BIGorilla 2 жыл бұрын
You’re welcome ☺️
@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.
@brij26579
@brij26579 2 жыл бұрын
Awesome 👌
@BIGorilla
@BIGorilla 2 жыл бұрын
Thanks ^^
@shivamkapoor1827
@shivamkapoor1827 Жыл бұрын
How can we do multiply two columns from different tables using custom function in power query??
@martyc5674
@martyc5674 2 жыл бұрын
Very useful 👍
@BIGorilla
@BIGorilla 2 жыл бұрын
Thank you!
@jafarhussain4665
@jafarhussain4665 3 ай бұрын
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
@minadev1
@minadev1 Ай бұрын
i did not quite get method 02 for indexing columns after dividing by group
@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!
@minadev1
@minadev1 Ай бұрын
I am an accounting person and wanted to learn Power BI, should I start working on M language too?
@ansonkong3813
@ansonkong3813 Жыл бұрын
I like the first method
@julliettecarignan8563
@julliettecarignan8563 6 ай бұрын
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 6 ай бұрын
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.
@user-yi1hd7io3h
@user-yi1hd7io3h 9 ай бұрын
In my case, I'm using a calculated table, but the issue is that calculated tables don't show up in Power Query.
@vncmra
@vncmra 7 ай бұрын
good morning, excellent work. what I need instead is that if the hill color group is popular and the color is black the index is one, if the two values ​​are equal, then popular and black in the next row the index is always 1 and so for the other rows . I look forward to seeing you post a similar video
@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 :)
@dirkstaszak4838
@dirkstaszak4838 2 жыл бұрын
I reckon number 3 is my favourite one
@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 жыл бұрын
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 :)
@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 жыл бұрын
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 ☺️
@SamehRSameh
@SamehRSameh 2 ай бұрын
How can make this but categorized on 2 level Exambe to clarify: France lion 1 France lion 2 France paris 1 France paris 2
@magnuskrook5618
@magnuskrook5618 5 ай бұрын
🎯 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
@williamarthur4801
@williamarthur4801 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 жыл бұрын
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 жыл бұрын
@@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 :)
@nicolasplanchon9986
@nicolasplanchon9986 Жыл бұрын
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 Жыл бұрын
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"}),
Transform Column Names in Bulk in Power Query
19:23
BI Gorilla
Рет қаралды 33 М.
Compute a ranking based on multiple columns
22:59
SQLBI
Рет қаралды 55 М.
تجربة أغرب توصيلة شحن ضد القطع تماما
00:56
صدام العزي
Рет қаралды 57 МЛН
Clowns abuse children#Short #Officer Rabbit #angel
00:51
兔子警官
Рет қаралды 73 МЛН
🤔Какой Орган самый длинный ? #shorts
00:42
Red❤️+Green💚=
00:38
ISSEI / いっせい
Рет қаралды 76 МЛН
Create a Running Total by Category in Power Query
17:44
BI Gorilla
Рет қаралды 28 М.
Create an Index Column for Subgroups in Power Query
6:46
Goodly
Рет қаралды 35 М.
Advanced Group By Tricks in Power Query
14:37
Goodly
Рет қаралды 89 М.
5 Surprising Power Query Tricks You Need to Know!
14:14
Goodly
Рет қаралды 30 М.
Power Query: Index and Modulo Functions
15:48
Geeky Veep
Рет қаралды 62 М.
Create custom keys for your Power BI relationships
9:44
Guy in a Cube
Рет қаралды 111 М.
Add index to nested tables in Power Query
5:41
Curbal
Рет қаралды 74 М.
Power Query - Alternate Group By Strategies
12:29
BCTI
Рет қаралды 3 М.
تجربة أغرب توصيلة شحن ضد القطع تماما
00:56
صدام العزي
Рет қаралды 57 МЛН