Merge Pivot Combined Columns into rows on Power Query

Aldonin

New Member
Joined
Jan 27, 2012
Messages
28
Hi, I'm creating a new thread since the problem I'm trying to solve is different to similar solutions which I've tried unsuccessfully.

I have a table with the following structure (see below), column "A" provides a list of cities A,D,B...D Column "B provides dates for the 1st date of an event happening at each city. Column "C" provides the dates for the second event at each city.

ABC
1​
CityDate 1Date 2
2​
A
4-Apr​
5-May
3​
B
5-Apr​
6-May
4​
C
6-Apr​
5​
D
7-Apr​
8-May
6​
7​
8​
9​

I'm trying to bring all the dates for both events into a single column as shown in the example below: Column "B". While I'm able to pivot columns into rows using Power Query's Split function (as learnt on a separate thread), I'm unable to solve this specific problem since the data across two separate columns "B" and "C".
Any Power Query ideas to solve this would be awesome, thanks in advance everyone!


ABC
1​
CityDate 1Date 2
2​
A4-Apr
3​
B5-Apr
4​
C6-Apr
5​
D7-Apr
6​
A5-May
7​
B6-May
8​
D8-May
9​
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Like this.

SJ_TableToExcel_Pivot.xlsx
ABCDEFG
1CityDate 1Date 2CityAttributeDate
2A4/4/20215/5/2021ADate 14/4/2021
3B4/5/20215/6/2021ADate 25/5/2021
4C4/6/2021BDate 14/5/2021
5D4/7/20215/8/2021BDate 25/6/2021
6CDate 14/6/2021
7DDate 14/7/2021
8DDate 25/8/2021
Sheet5


Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    Unpivot = Table.UnpivotOtherColumns(Source, {"City"}, "Attribute", "Date")
in
    Unpivot
 
Upvote 0

Forum statistics

Threads
1,223,714
Messages
6,174,058
Members
452,542
Latest member
Bricklin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top