Really enjoyed the video, and found the use of the functions a great learning experience. For this example I think the list of names can be replaced with the number of columns, so you could have used the max number straight in the argument, although the video was more informative using the other way = let _max = List.Max(Table.AddColumn(Source,"Custom",each List.Count(Text.PositionOfAny([Hobbies],{","},Occurrence.All)))[Custom])+1 in Table.SplitColumn(Source, "Hobbies",Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv),_max)
Really amazing. Dynamic columns, even outside split, remains a very challenging area - like pivoting and unpivoting a dynamic list of columns. This video definitely helps.
Great idea. I love the way you conserve steps and combine so much into each one. I do see an issue that will come up with steps beyond these dynamic columns. But I suppose that can be handled as the cases arise.
The BEST TEATCHER EVER about Power Query (M) language. Loving all videos about it. Thank you a lot for your great and amazing commitment to help world community. I wish all the best to you and your family!
Thanks, Chandeep, I liked the part which you use Text.PositionOf for AllOccurance but for split by variable columns why do you make it really complicated?!!! Just remove the list in the last argument of Table.SplitColumn function. (then it will be dynamic for new columns)😉
This only works if the first row happens to have the max delimiters required, I have tried, and lets say if the first record has 2 delimiters, then you get 3 columns and no more.
@@martyc5674 Of course, I reached to this point and the solution is making Custom column as =List.Count(List.Split([Hobbies],",")) And before split, we must sort z to a this custom column. Still easier.
I did this solution some time ago more for a "sport" activity. However, the easier way is to use to Text.Split which will convert the text into list, and then expand the list.
Chandeep, how do i dynamically split up to the second last value in PBI for each record? For e.g. I have a table with EE hierarchy for each user- For John, hierarchy is User1.User2.User3.User4 If John is User4, I want to split his hierarchy till User3. For Jane, hierarchy is User1.User2.User3.User4.User5 If Jane is User5, I want to split her hierarchy till User4 With the current setup, the columns are split into 5 columns by default, as there are 5 users in the table. So even though John is User4, the columns are split into 5 columns, where the 4th column consists of John's name. This is how the columns are split: User 1 | User 2 | User 3 | User 4 | User 5 M1 | M2 | M3 | John | NULL M1 | M2 | M3 | M4 | Jane I want the columns to stop at User 3 for John, so column USER 4 should be NULL as well Any way to split the columns based on each record, rather than looking at the maximum number of splits in the table?
Other functions, e.g. Text.Combine uses a list to reference the columns to be combined. So far I was unable to define a list similar to this example to get this function working. Was anybody more successful with Text.Combine? Seb
I have a table with three columns Col1 … Col3. I merge the columns into a new column via add column / merge column with gives this M code: = Table.AddColumn(Source, "ColCombine", each Text.Combine({[Col1], [Col2], [Col3]}, "|"), type text) I wanted to do something similar to your video that I have a formula like = Table.AddColumn(Source, "ColCombine", each Text.Combine(ListColHeading, "|"), type text) So far I did not manage to create a List that the content of [Col1], [Col2], [Col3] is referenced - did I explain okay?
A possible solution is using Table.CombineColumns instead of merging the columns into a new column. The steps to perform are - Creating the list “ColList” from the tables header - Transforming every column into type text using “ColList“ in combination with Table.TransformColumnTypes - Applying Table.CombineColumns in combination with “ColList“ Code could look like this: Source … IntoText = Table.TransformColumnTypes(Source, List.Transform(ColList, each {_, type text})), CombineCols = Table.CombineColumns(IntoText,ColList,Combiner.CombineTextByDelimiter(":", QuoteStyle.None),"ColsCombined") I got the inspiration for this from the video 😉 ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-1fn8fXYw6M4.html
Great presentation - excellent walkthrough of the critical thinking and problem-solving technique. I wonder if there's a way to do it in DAX, as well... Also... I, too, enjoy Hulking. Excellent choice, Rehet.
This tutorial is great but it's not meeting my needs exactly. My issue is I have a list of names and I want to split them into columns by First Name, Middle Name or Initial, Last Name, and Suffix name. Not all have a suffix, middle int/name or period. when I split them last names go into the middle name column and I don't know how to bring it to the right column. When I split the delimiter one step at a time by the first name it's in the right column but when I split the second time I run into problems. How do I fix this?
Thank you so much! I am having a problem in that I need to split a column up to 15 characters for example. The column has characters up to 15 and then a space and then another set of characters but within those first 15 characters there can also be spaces, So I can’t split by the delimiter of a space. And I can’t split by 15 characters because sometimes it is less than 15 characters. I need to make the split dynamic but I am very lost on what to tell it to do.
Came across your video trying to solve this exact problem today. I needed to separate a list in a cell to separate columns prior to unpivoting. Your explanation was terrific and probably the most straightforward solution I've come across. Thanks!
I found a bug in the split function while working with a large dataset. I was manually applying a sequence of commands, with the split function in the middle. I was splitting a column using the delimiter ";;;". The columns had a varying number of delimiter occurrences, but I expected them to consistently generate 4 or 5 columns each. Only later did I realize that the split function was only generating 2 columns. I had to re-run the split operation, and only then did it generate the correct number of columns. Now, whenever I apply the split command, I wait for it to show the detected number of columns before applying it again.
Very interesting tutorial. But you didn't foresee that in the future you might list a little friend of your friends and that he will have other hobbies, for example football and Crying, just two hobbies, but football would deserve a new separate column and the current formula does not provide for this case .... :) :) Greetings.
Awesome trick however is there a way to sort the information. Let's say you asked 100 people and they chose a hobby but it appears any of them columns in the order it was split. Maybe you want a column based on the hobby type.
Thanks for the explanation. I've shorten it a bit. This avoids me having to clean up added columns in the end. The 'n' column, that contains the number of occurrences for ';' exists only inside the MaxAnswers step. I could also add it and then refer to a previous step, true... MaxAnswers = List.Max(Table.AddColumn(Source, "n", each List.Count(Text.PositionOf([Answers], ";", Occurrence.All)) + 1)[n]), HeadersAnswers = List.Transform({1..MaxAnswers}, each "Answer"&Text.From(_)),
Wow 😲 Chandeep Amazing!, what a technique you taught. Please solve my problem also which I commented in another's video. How can I pass dynamic list into table.combine function.
wow, this just came just at the right time. I have a use case where I have to do a report on dynamic product category/products. Just subscribed. thanks!
This solved my main issue to learn m code how to modify but couldn't we split the hobies by delimiter by row and then we get a unique list and refer that list this would solve issue if you have duplicate entries...
Brilliant!! This is exactly what I was looking for about a year ago, but I couldn't quite work out how to do it. I can't wait to implement this. I really like the way you explained all the step. THANK YOU!!! I have just subscribed :)