Power Query: Emerging from Merging
13 November 2019
Welcome to our Power Query blog. This week we look at extracting from merged Excel cells.
I have some data from John, one of my imaginary salespeople:
![](http://sumproduct-4634.kxcdn.com/img/containers/main/blog-pictures/2019/power-query/154/image1.png/e774d10cbbb9450fc45efbe51abdf434.jpg)
John has almost followed the expected format, but he’s decided to merge the date cells instead of using auto fill. I need the date on each row. I begin by extracting the data to Power Query by using the ‘From Table’ option on the ‘Get & Transform’ section of the Data tab.
![](http://sumproduct-4634.kxcdn.com/img/containers/main/blog-pictures/2019/power-query/154/image2.png/f32e5a15e2cf9c3e4d2d058458ce054d.jpg)
I accept the defaults.
![](http://sumproduct-4634.kxcdn.com/img/containers/main/blog-pictures/2019/power-query/154/image3.png/f1140ff857fc3b6f5f97a6a24f4a6fc7.jpg)
I can sort out my data by using ‘Fill Down’ which is available from the ‘Transform’ tab or if I right click on a selected column, viz.
![](http://sumproduct-4634.kxcdn.com/img/containers/main/blog-pictures/2019/power-query/154/image4.png/72aa864d2854c6fefb1083fba0ab5792.jpg)
I select ‘Fill’ and ‘Down’.
![](http://sumproduct-4634.kxcdn.com/img/containers/main/blog-pictures/2019/power-query/154/image5.png/36776d1da4d05b45bb5a5d09375f407c.jpg)
The dates are now populated correctly. However, there are other ways that John likes to merge cells in Excel:
![](http://sumproduct-4634.kxcdn.com/img/containers/main/blog-pictures/2019/power-query/154/image6.png/23912d3b1671861e02bebcd5183f1607.jpg)
In this case he’s merged ‘Contact 1’ and ‘Contact 2’ for two the dates, as well as merging the rows. I extract this data again into Power Query:
![](http://sumproduct-4634.kxcdn.com/img/containers/main/blog-pictures/2019/power-query/154/image7.png/6f49c288a0d88a66b427eaf4ece923d6.jpg)
I can see that the Contact 2 column is currently redundant, so I will remove it using the ‘Remove Columns’ option on the Home tab and create a new one.
![](http://sumproduct-4634.kxcdn.com/img/containers/main/blog-pictures/2019/power-query/154/image8.png/b9ee28d90e6b5bc92ea4aeafdad51628.jpg)
I can now fill down as before.
![](http://sumproduct-4634.kxcdn.com/img/containers/main/blog-pictures/2019/power-query/154/image9.png/0485ccbc83bdeec1d741bad442a1ea5f.jpg)
I need to split Contact 1, so I use ‘Split Column’ from the ‘Transform’ tab.
![](http://sumproduct-4634.kxcdn.com/img/containers/main/blog-pictures/2019/power-query/154/image10.png/daf8c4f0259ce428269c0d3d4badd32b.jpg)
I split by delimiter, but I need to create two new columns, not three, so I won’t split for every occurrence of SPACE.
![](http://sumproduct-4634.kxcdn.com/img/containers/main/blog-pictures/2019/power-query/154/image11.png/22c6daeb82d7d69ac88f878227e04b28.jpg)
I choose to split at the ‘Right-most delimiter’.
![](http://sumproduct-4634.kxcdn.com/img/containers/main/blog-pictures/2019/power-query/154/image12.png/a1537847463e660a31158c8032525438.jpg)
Now I need to remove the ‘and’ from the names in Contact 1.1. There are several ways I can approach this. I can split the column again and delete the column with ‘and’. Another way is to create a custom column. In this example, I will use ‘Add Column by Examples’ on the ‘Add Column’ tab to see which method Power Query applies.
![](http://sumproduct-4634.kxcdn.com/img/containers/main/blog-pictures/2019/power-query/154/image13.png/917da985be13220165c8d2823e95344f.jpg)
After only one example, Power Query has opted to transform the column so that only the characters before the SPACE delimiter appear:
= TextBeforeDelimiter([Contact 1.1],"")
![](http://sumproduct-4634.kxcdn.com/img/containers/main/blog-pictures/2019/power-query/154/image14.png/8c3be7af9f73d031acae69ed85a2e148.jpg)
I remove the column I no longer need and rename the contact information. I also reorder my data.
![](http://sumproduct-4634.kxcdn.com/img/containers/main/blog-pictures/2019/power-query/154/image15.png/e63c0a4c21afc9afb438aacc09a59317.jpg)
I now have the data in a standard format so that I can append it to data from other salespeople.
Come back next time for more ways to use Power Query!