Тёмный

Power Query Convert Columns to Rows for groups and expand columns dynamically in 2 ways 

Access Analytic
Подписаться 89 тыс.
Просмотров 44 тыс.
50% 1

🔽More Information below🔽
This Power Query challenge uses GroupBy, List functions and a little hack
There's also a trap with expanding the columns if the number of columns may change. I show 2 ways of doing that.
Thanks to everyone for taking part. You can download the challenge file if you want to try this out, and also my solution (and everyone elses) is available here too
accessanalytic.com.au/power-q...
I love reading your comments and questions so feel free to post those
Here's a link to the my video of a 3rd solution: • Power Query Pivot and ...
Thanks to these folks for taking part, solutions are saved in the same folder as per the link above
Alexander Sorokopyt
Andrew Shepley
Bohdan Duda
Chandeep Chhabra
Christopher Hazel
Daniil Maslyuk
Daryl Lynch
Diana Maria Iordachescu
Dyota
Glyn Willis
Guido
Henriette
Ivan Dumalovski Janjušić
Jan Berny
Kolyu
Leon Dijkers (winner of the first person to submit a solution award 😀 )
Nick Bonner
Nizam
Peter Tholstrup
Philip Treacy
Quadri Atharu
Sham F
Steve Bateman
Follow me on various platforms: wyn.bio.link/
Cheers
Wyn

Хобби

Опубликовано:

 

29 июн 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 116   
@Mister_Bates
@Mister_Bates 2 года назад
Thanks for replying to my solution email - and loved seeing similar elements in your solution! A few things I learned from your solution: 1) Adding an index to "fix" the sort rather than Table.Buffer - I'm with you on this, PQ can forget the sort. 2) Extracting a list from the grouped tables in the Data column - nice technique 3) Using nQual as a parameter to Text.SplitByDelimiter I'm loving these challenges - keep them coming!
@AccessAnalytic
@AccessAnalytic 2 года назад
Thanks Steve, great that you and everyone are taking part and watching the solutions
@ccentermanager
@ccentermanager Год назад
i was just looking for that solution for over a week!!!! thanks!!! great tutorial
@AccessAnalytic
@AccessAnalytic Год назад
Glad to help 🙂
@malejandrahorvath
@malejandrahorvath 2 года назад
Thank you Wyn 😊 Learning so much from you, as always! The second approach is my favorite one 🤯
@AccessAnalytic
@AccessAnalytic 2 года назад
Thanks Alejandra, yep it's more elegant and easier to implement in more complex scenarios
@rick_.
@rick_. 2 года назад
As always I learn something new from you videos, and I thank you!
@AccessAnalytic
@AccessAnalytic 2 года назад
Cheers Rick, glad I'm helping out
@IvanCortinas_ES
@IvanCortinas_ES 2 года назад
Thank you!! Congrats for the 10K, and for the new logo. That's an excellent channel!
@AccessAnalytic
@AccessAnalytic 2 года назад
Thank you Iván
@wayneedmondson1065
@wayneedmondson1065 2 года назад
Awesome Wyn! Great demo. Thanks for the two examples. Learned a lot! Thumbs up!!
@AccessAnalytic
@AccessAnalytic 2 года назад
Thanks Wayne.
@MrJoking4fun
@MrJoking4fun 4 месяца назад
This was extremely helpful!
@AccessAnalytic
@AccessAnalytic 4 месяца назад
I appreciate you taking the time to let me know you found it useful
@khawarmalik5239
@khawarmalik5239 2 года назад
Second approach is super cool. I knew about the first one having used it on lot of occasions but the second one is amazing. Thanks for sharing his. 👍👍👍👍
@AccessAnalytic
@AccessAnalytic 2 года назад
Great, we all keep learning. Thanks for leaving a great comment
@handlegich
@handlegich 10 месяцев назад
This is such a massive time saver! I am now interested in the M code!!! Thank you and keep up the good job.
@AccessAnalytic
@AccessAnalytic 10 месяцев назад
Cheers, getting into M opens a whole new world of options
@mirrrvelll5164
@mirrrvelll5164 2 года назад
Great trick! It is amazing and interesting to follow you along!
@AccessAnalytic
@AccessAnalytic 2 года назад
Glad you’re finding it interesting 😀
@jazzista1967
@jazzista1967 2 года назад
Great video. I liked your second approach using the nQuail name and replace the list hardecoded by the M code.
@AccessAnalytic
@AccessAnalytic 2 года назад
Thanks for watching and leaving a comment
@sedarathnadcd
@sedarathnadcd Год назад
Thank you Wyan. I learned a lot from your Vedios. 2nd method is more attractive and my favourite. Thank you sharing your valuable knowledge.
@AccessAnalytic
@AccessAnalytic Год назад
You’re welcome Priya. Thanks for taking the time to leave a kind comment
@tomr9969
@tomr9969 2 года назад
Nice! I was on the right path (grouping) and lost track of time. Having said that, I learn by doing - I am going to do both steps tonight! Thanks for sharing!
@AccessAnalytic
@AccessAnalytic 2 года назад
You're welcome Tom, thanks
@matthewwykle8965
@matthewwykle8965 2 года назад
Just found your challenges. A lot of fun. You can turn off the automatic changed type steps. Data>Get Data> Query Options>Data Load>Type Detection. You can do it for all workbooks (Global) or individual workbooks as needed.
@AccessAnalytic
@AccessAnalytic 2 года назад
Yep, cheers Matthew. For this demo it would have been good to turn it off
@johnhackwood1568
@johnhackwood1568 2 года назад
Another gem of a video thank you Wyn. If you had just shown the first and left it there that would have been good enough but the 2nd approach, voila!
@AccessAnalytic
@AccessAnalytic 2 года назад
😀 I’ll be demoing a clever 3rd option that several people submitted in a week or two. All good learning for all of us
@shahidabano7094
@shahidabano7094 Год назад
This helped a lot. Saved my time! Thanks.
@AccessAnalytic
@AccessAnalytic Год назад
Great! Thanks for taking the time to leave a kind comment
@darlenesoukhaphonh8437
@darlenesoukhaphonh8437 Год назад
Exactly what I needed! Thanks!
@AccessAnalytic
@AccessAnalytic Год назад
Glad to help Darlene
@davidb7511
@davidb7511 4 месяца назад
BRILLIANT STUFF!!! Just what I needed...
@AccessAnalytic
@AccessAnalytic 4 месяца назад
You’re welcome. Thanks for taking the time to to let me know it was useful
@mirziyodm
@mirziyodm Год назад
Thanks so much, that was just what I was looking for!
@AccessAnalytic
@AccessAnalytic Год назад
Great, thanks for taking the time to leave a kind comment
@GrainneDuggan_Excel
@GrainneDuggan_Excel 2 года назад
PQ forgot the sort order in my solution to this challenge. I had to sort again at a later step. Definitely still a thing. Thanks for the solution,Wyn
@AccessAnalytic
@AccessAnalytic 2 года назад
Thanks for confirming Grainne
@ivandumalovskijanjusic1159
@ivandumalovskijanjusic1159 2 года назад
Thanks for the challenge, it was fun and educational, as Power BI should be 🙂
@AccessAnalytic
@AccessAnalytic 2 года назад
Cheers Ivan, thanks for taking part
@Bhavik_Khatri
@Bhavik_Khatri 2 года назад
Wow, very nice tricks. Thank you very much for sharing.
@AccessAnalytic
@AccessAnalytic 2 года назад
You’re welcome Bhavik
@leebecker8255
@leebecker8255 Год назад
Oooh I didn't realised you can use a number on the second argument of the splitcolumn function. What a game changer! 😁
@AccessAnalytic
@AccessAnalytic Год назад
Glad it helps
@Luciano_mp
@Luciano_mp 2 года назад
Amazing, great, i liked. Thank you!
@AccessAnalytic
@AccessAnalytic 2 года назад
Thanks Luciano
@miracleugwu5603
@miracleugwu5603 Год назад
Thank you so much. You're a life saver.
@AccessAnalytic
@AccessAnalytic Год назад
You're welcome :)
@RaviGupta-mo1nf
@RaviGupta-mo1nf 2 года назад
Interesting problem to solve & I loved the solutions you offered. To make it more interesting ( or for use at work), add year in which the qualification was acquired. Employee can acquire more than 1 qualification in any year :)
@AccessAnalytic
@AccessAnalytic 2 года назад
Thanks for the suggestion Ravi
@pranipradani9853
@pranipradani9853 Год назад
Thank you for saving me timess 🙏🙏
@AccessAnalytic
@AccessAnalytic Год назад
You’re welcome thanks for taking the time to leave a kind comment
@TheLaopi
@TheLaopi Год назад
Amazing, i haveto learn a lot to have your level
@AccessAnalytic
@AccessAnalytic Год назад
Every year I say the same thing about future me 😀
@pkup10
@pkup10 5 месяцев назад
Really helpful. Thanks.
@AccessAnalytic
@AccessAnalytic 5 месяцев назад
You’re welcome. I appreciate you taking the time to let me know you found it useful
@martyc5674
@martyc5674 2 года назад
Hi Wyn- Great Vid, ** Edit the below is incorrect, I was mixing up with table.split function. however I learned something the other day about the splittextbydelimiter function, the last argument is optional. All you need to do is delete the list and your done, no need to do nQuals or anything fancy. Your formula at 11:19 is actually all that’s needed. Just leave the last part blank and it’s totally dynamic.
@AccessAnalytic
@AccessAnalytic 2 года назад
Thanks Martin, Sadly that doesn’t actually work properly, it just splits the first record dynamically by the number of delimiters it has. Any subsequent records with more delimiters don’t get split
@martyc5674
@martyc5674 2 года назад
@@AccessAnalyticI stand corrected , it was the table.split function where this works without passing something to the last argument(and then becomes dynamic). I jumped the gun, and expected similar behaviour with this function. Let me see if I can leverage the table.split function to form a solution to this problem.
@martyc5674
@martyc5674 2 года назад
So I tried this again today, and turns out I’m completely wrong. I just got lucky(read fooled!!) with the small bit of test data I was using, as it happened to have the most delimiters in the first record. So to my dismay the behavior Wyn highlighted is also true in the table.split function 🥲🥲
@AccessAnalytic
@AccessAnalytic 2 года назад
Thanks for letting folks know, I think I’ve been caught by this is the past, I may even have a video where I used it
@SamehRSameh
@SamehRSameh 2 года назад
Marvelous ideas 💡💡
@AccessAnalytic
@AccessAnalytic 2 года назад
Thanks Sameh
@mahnoorafridi9872
@mahnoorafridi9872 Год назад
Thank you soo much for this video
@AccessAnalytic
@AccessAnalytic Год назад
You’re welcome 😀
@monserratabarca5563
@monserratabarca5563 Год назад
Beautiful!
@AccessAnalytic
@AccessAnalytic Год назад
Thank you
@williamarthur4801
@williamarthur4801 Год назад
Really enjoyed that, loved the unpivot, pivot, I always get confused with that and it's a bit trial and error, I also forget about using the aggregations in grouping and tend to type everything in the editor , when it came to a dynamic column count I used; List.Max ( List.Transform( Custom2 [List of Lists], (_)=>List.Count(_)) )
@AccessAnalytic
@AccessAnalytic Год назад
Thank you
@zachg.9208
@zachg.9208 2 года назад
Really nice, thanks.
@AccessAnalytic
@AccessAnalytic 2 года назад
No worries Zach
@chrisharmozi4527
@chrisharmozi4527 2 года назад
Your videos are really nice.👍 I Subscribed you just now🙂
@AccessAnalytic
@AccessAnalytic 2 года назад
That's great Krishna, thanks
@jenniferrussell1674
@jenniferrussell1674 Год назад
Thank you!!
@AccessAnalytic
@AccessAnalytic Год назад
You’re welcome Jennifer
@kayodeogundiya7194
@kayodeogundiya7194 2 года назад
First approach is cool for me
@AccessAnalytic
@AccessAnalytic 2 года назад
Yeah I like it too, thanks Kayode
@MegaNadine2012
@MegaNadine2012 7 месяцев назад
Thank you very much
@AccessAnalytic
@AccessAnalytic 7 месяцев назад
You’re welcome
@teoxengineer
@teoxengineer 2 года назад
Thank you so much for this tutorial. I would like to learn that what is the main diffrence between List and Table?
@AccessAnalytic
@AccessAnalytic 2 года назад
You're welcome. A list is a collection of items {A,B,C} that looks like a column. A Table consists of rows and columns (records). A single column Table looks very much like a list It's multiple related columns that really separate a table from a list
@sharadgupta2007
@sharadgupta2007 2 года назад
Great🙏🙏
@AccessAnalytic
@AccessAnalytic 2 года назад
Thankyou
@jarosawpapierski2530
@jarosawpapierski2530 Год назад
I would like to thank you for this video. I was struggling with this for a quite long time. Is there any way to support you? Or at least give you coffee?
@AccessAnalytic
@AccessAnalytic Год назад
Greatly appreciated. Just let people know about the channel and that you found it useful! Thanks 🙏🏻
@azmf80
@azmf80 Год назад
Great 👍
@AccessAnalytic
@AccessAnalytic Год назад
You're welcome
@ryanyou1583
@ryanyou1583 2 года назад
my approach is Group then use ''text.combine'' then Split. it should be quicker =)
@AccessAnalytic
@AccessAnalytic 2 года назад
Feel free to submit a file or code Ryan
@vinmeg69
@vinmeg69 3 дня назад
Hello Wyn thanks, Leads me to a question: How to get the qualifications in a sort order with columns per qualification? A Accountant Column, Plumber Column etc.
@AccessAnalytic
@AccessAnalytic День назад
A groupby and then add a grouped index. Paste this into the advanced editor to see how it works let // Summary: This query processes a table from Manually entered table (saved as Json, removes unnecessary columns, groups rows by 'Qual', adds an index column, pivots the table, and cleans up the final output. // Developed by: access analytic // Source: Load and decompress JSON data into a table Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUQpJTUzOUIrViVZyQuE5A3mOycklYI4LkBOQU5oL5rgCOcH5OSmZqUVKsbEA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Name = _t, Qual = _t]), // GroupedRows: Group the table by 'Qual' column GroupedRows = Table.Group(Source, {"Qual"}, {{"Data", each _, type table [Name = nullable text, Qual = nullable text]}}), // AddedIndex: Add an index column to each grouped table AddedIndex = Table.AddColumn(GroupedRows, "Custom", each Table.AddIndexColumn([Data], "Index", 1, 1)), // KeptOnlyCustom: Select only the 'Custom' column KeptOnlyCustom = Table.SelectColumns(AddedIndex, {"Custom"}), // ExpandedCustom: Expand the 'Custom' column into 'Name', 'Qual', and 'Index' columns ExpandedCustom = Table.ExpandTableColumn(KeptOnlyCustom, "Custom", {"Name", "Qual", "Index"}, {"Name", "Qual", "Index"}), // PivotedQual: Pivot the table on 'Qual' column, transforming 'Name' values into respective 'Qual' columns PivotedQual = Table.Pivot(ExpandedCustom, List.Distinct(ExpandedCustom[Qual]), "Qual", "Name"), // RemovedIndex: Remove the 'Index' column from the pivoted table RemovedIndex = Table.RemoveColumns(PivotedQual, {"Index"}) in RemovedIndex
@CasperLind1
@CasperLind1 10 месяцев назад
Fix for : 4:55 (making a list) - try write only writting = [Data][Qualification]
@AccessAnalytic
@AccessAnalytic 10 месяцев назад
Yep, nice shortcut
@antonysovy5887
@antonysovy5887 2 года назад
It's great
@AccessAnalytic
@AccessAnalytic 2 года назад
Thanks Antony
@antonysovy5887
@antonysovy5887 2 года назад
@@AccessAnalytic thanks to You for sharing all theese interesting videos.
@AccessAnalytic
@AccessAnalytic 2 года назад
You’re welcome
@pthapa55
@pthapa55 4 месяца назад
Can you please have a short video on splitting columns to rows with aggregated data, like sales amount. Thank you
@AccessAnalytic
@AccessAnalytic 4 месяца назад
Can you expand on what the issue is you’re trying to solve?
@pthapa55
@pthapa55 4 месяца назад
Example: What is your email, I can send the sample in the email.@@AccessAnalytic Thank you
@ravipaul1657
@ravipaul1657 Год назад
thanks but can we achieve the result as vice versa.
@AccessAnalytic
@AccessAnalytic Год назад
Sure there’s almost always a way to do anything as long as there’s some logical pattern
@hermonkidane1503
@hermonkidane1503 Год назад
I want the same thing but the reverse, meaning I want to map multiple rows to a single column, if there is name and say salary of each month in a single row, I would like to have name then each month salary vertically in multiple rows, then the name of the next employee salary of each month vertically and so on...Can any one give me a hint of how to do that.
@AccessAnalytic
@AccessAnalytic Год назад
Maybe unpivot? ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-ESap6ptV8fI.html
@FRANKWHITE1996
@FRANKWHITE1996 Год назад
🙌🙌🔥🔥🙏🙏
@AccessAnalytic
@AccessAnalytic Год назад
😀
@atiqkhan9637
@atiqkhan9637 Год назад
that great WYN, HOW CAN WE SOLVE THE SAME PROBLEM IN EXCEL
@AccessAnalytic
@AccessAnalytic Год назад
Not sure what you mean, this is in Excel
@amanijeanpierre7911
@amanijeanpierre7911 2 года назад
How do we extract get data from web using Power Query containing more data in a table than it appears on the websites. Such websites show tables in pages so you need to click page 2 for you to see the next content.
@AccessAnalytic
@AccessAnalytic 2 года назад
This video may give you some ideas on that ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-BZuX5zD8sUA.html
@crumbdav
@crumbdav 7 месяцев назад
Wait, isn't this rows to columns?
@AccessAnalytic
@AccessAnalytic 7 месяцев назад
It;s a bit more involved than that, but you could like do some combination of UNQIUE and then FILTER and TOROWS to get a similar result
@ExcelWizard
@ExcelWizard 2 года назад
Great challenge My approach by Table.FromRows and Table.Combine let Source = Excel.CurrentWorkbook(){[Name="tblQualifications"]}[Content], Sorted = Table.Buffer(Table.Sort(Source,{{"Name", Order.Ascending}, {"Qualification", Order.Ascending}})), Grouped = Table.Group(Sorted, {"Name"}, {{"T", each Table.FromRows({{[Name]{0}}&[Qualification]} ,{"Name"}&List.Transform({1..Table.RowCount(_) }, each "Qualification."&Text.From(_))) }}), Combine = Table.Combine(Grouped[T]) in Combine
@AccessAnalytic
@AccessAnalytic 2 года назад
Thanks for joining in!
Далее
Convert Multiple Column Groups to Rows in Power Query
17:18
3M❤️ #thankyou #shorts
00:16
Просмотров 3,5 млн
3 Essential Excel skills for the data analyst
18:02
Просмотров 1,5 млн
Combining Excel Tables in a highly flexible way
12:18
ОЧЕНЬ ВКУСНЫЙ БУТЕРБРОД 🍞
0:49