Power Query: I Gather That’s Right
9 December 2020
Welcome to our Power Query blog. This week, I look at how to gather data from multiple rows.
Just for a change, I have some tent data…
I want to present one line for each Tent / Awning combination, with any accessories appearing as a list, e.g. ‘Medium Package Groundsheet, Lights’. I begin by extracting my data to Power Query using the ‘From Table’ option on the ‘Get & Transform’ section of the Data tab.
I take the defaults:
I am going to group my data, and I can do this from the Transform tab.
I use the ‘Group By’ functionality, viz.
I have used the Advanced options to that I can group by Tent and then Awning, and I put all the data gathered into a new column called AccessoryList.
This gives me a column for each unique Tent / Awning combination, plus a table column.
If I click in the white space next to the word ‘Table’ I can see the data included in that table.
Next, I create a new custom column from the ‘Add Column’ tab which will contain just the accessory data.
I have treated AccessoryList as a table, and selected Accessories from that table.
This has created a list of the accessories. Now I need to format the list the way I want it.
If I click on the expansion symbol next to the title of Accessories, I can choose to ‘Extract Values’.
I can use a delimiter; I choose a comma.
I can now remove the table column and I have my data the way I want to present it.
Come back next time for more ways to use Power Query!