Power Query: Rows of Columns
11 September 2019
Welcome to our Power Query blog. Today, I split a column into rows.
I have received some sales data from John, my favourite imaginary salesperson. He’s decided to merge some of his data.
![](http://sumproduct-4634.kxcdn.com/img/containers/main/blog-pictures/2019/power-query/145/image1.png/e774d10cbbb9450fc45efbe51abdf434.jpg)
I have a list of companies on each line, instead of one row for each company. I want to have one row per company so that I can link to other company data.
I start by extracting my data to Power Query using ‘From Table’ on the ‘Get & Transform’ section of the ‘Data’ tab:
![](http://sumproduct-4634.kxcdn.com/img/containers/main/blog-pictures/2019/power-query/145/image2.png/f32e5a15e2cf9c3e4d2d058458ce054d.jpg)
I keep the headings and create my table.
![](http://sumproduct-4634.kxcdn.com/img/containers/main/blog-pictures/2019/power-query/145/image3.png/f1140ff857fc3b6f5f97a6a24f4a6fc7.jpg)
I want to split the column Company. I select this column and right-click to see the options:
![](http://sumproduct-4634.kxcdn.com/img/containers/main/blog-pictures/2019/power-query/145/image4.png/72aa864d2854c6fefb1083fba0ab5792.jpg)
I can split my column ‘By Delimiter…’, so I choose this option.
![](http://sumproduct-4634.kxcdn.com/img/containers/main/blog-pictures/2019/power-query/145/image5.png/36776d1da4d05b45bb5a5d09375f407c.jpg)
I can choose to split by semicolon (;) – however, I don’t want to split into multiple columns, as each separate piece of data will be a company, so I look at the ‘Advanced options’ available.
![](http://sumproduct-4634.kxcdn.com/img/containers/main/blog-pictures/2019/power-query/145/image6.png/23912d3b1671861e02bebcd5183f1607.jpg)
I can split into rows, so I choose this option instead.
![](http://sumproduct-4634.kxcdn.com/img/containers/main/blog-pictures/2019/power-query/145/image7.png/6f49c288a0d88a66b427eaf4ece923d6.jpg)
I now have a row for each company, with one simple step (and no M code knowledge required!). The generated M code is:
= Table.ExpandListColumn(Table.TransformColumns(#"Changed Type", {{"Company", Splitter.SplitTextByDelimiter(";", QuoteStyle.Csv), let itemType = (type nullable text) meta [Serialized.Text = true] in type {itemType}}}), "Company")
This has used the M function Table.ExpandListColumn():
Table.ExpandListColumn(table as table, column as text) as table
Given a column of list data in a table, this creates a copy of a row for each value in its list.
Power Query has converted the Company column to a column of lists by using Splitter.SplitTextByDelimiter(), and then converted that list into rows. In this case, my data was delimited by a simple semicolon, but there are also options to use special characters, making this a very powerful function when dealing with complex columns.
![](http://sumproduct-4634.kxcdn.com/img/containers/main/blog-pictures/2019/power-query/145/image8.png/b9ee28d90e6b5bc92ea4aeafdad51628.jpg)
Come back next time for more ways to use Power Query!