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…
![](http://sumproduct-4634.kxcdn.com/img/containers/main/blog-pictures/2020/power-query/210/image1.png/e774d10cbbb9450fc45efbe51abdf434.jpg)
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.
![](http://sumproduct-4634.kxcdn.com/img/containers/main/blog-pictures/2020/power-query/210/image2.png/f32e5a15e2cf9c3e4d2d058458ce054d.jpg)
I take the defaults:
![](http://sumproduct-4634.kxcdn.com/img/containers/main/blog-pictures/2020/power-query/210/image3.png/f1140ff857fc3b6f5f97a6a24f4a6fc7.jpg)
I am going to group my data, and I can do this from the Transform tab.
![](http://sumproduct-4634.kxcdn.com/img/containers/main/blog-pictures/2020/power-query/210/image4.png/72aa864d2854c6fefb1083fba0ab5792.jpg)
I use the ‘Group By’ functionality, viz.
![](http://sumproduct-4634.kxcdn.com/img/containers/main/blog-pictures/2020/power-query/210/image5.png/36776d1da4d05b45bb5a5d09375f407c.jpg)
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.
![](http://sumproduct-4634.kxcdn.com/img/containers/main/blog-pictures/2020/power-query/210/image6.png/23912d3b1671861e02bebcd5183f1607.jpg)
This gives me a column for each unique Tent / Awning combination, plus a table column.
![](http://sumproduct-4634.kxcdn.com/img/containers/main/blog-pictures/2020/power-query/210/image7.png/6f49c288a0d88a66b427eaf4ece923d6.jpg)
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.
![](http://sumproduct-4634.kxcdn.com/img/containers/main/blog-pictures/2020/power-query/210/image8.png/b9ee28d90e6b5bc92ea4aeafdad51628.jpg)
I have treated AccessoryList as a table, and selected Accessories from that table.
![](http://sumproduct-4634.kxcdn.com/img/containers/main/blog-pictures/2020/power-query/210/image9.png/0485ccbc83bdeec1d741bad442a1ea5f.jpg)
This has created a list of the accessories. Now I need to format the list the way I want it.
![](http://sumproduct-4634.kxcdn.com/img/containers/main/blog-pictures/2020/power-query/210/image10.png/daf8c4f0259ce428269c0d3d4badd32b.jpg)
If I click on the expansion symbol next to the title of Accessories, I can choose to ‘Extract Values’.
![](http://sumproduct-4634.kxcdn.com/img/containers/main/blog-pictures/2020/power-query/210/image11.png/22c6daeb82d7d69ac88f878227e04b28.jpg)
I can use a delimiter; I choose a comma.
![](http://sumproduct-4634.kxcdn.com/img/containers/main/blog-pictures/2020/power-query/210/image12.png/a1537847463e660a31158c8032525438.jpg)
I can now remove the table column and I have my data the way I want to present it.
![](http://sumproduct-4634.kxcdn.com/img/containers/main/blog-pictures/2020/power-query/210/image13.png/917da985be13220165c8d2823e95344f.jpg)
Come back next time for more ways to use Power Query!