Power Query question - how to append two existing columns to be under 2 other columns?

ExcelOnTheClock

New Member
Joined
Dec 1, 2022
Messages
19
Office Version
  1. 365
Platform
  1. Windows
Hello,

How can I get columns 3 and 4 to be below columns 1 and 2?

1701274845766.png


If it's possible to do this without using custom M code, that would be ideal! All good if I have to though.

Thanks in advance for any help!
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
You can indeed create a duplicate table. Here another solution.

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    colNames = {{"Column1", "Column2"},{"Column3", "Column4"}},
    FirstTwo = Table.SelectColumns(Source,colNames{0}),
    LastTwo = Table.RenameColumns(Table.SelectColumns(Source,colNames{1}), List.Zip({colNames{1},colNames{0}})),
    result = Table.Combine({FirstTwo,LastTwo})
in
    result


Book1
ABCD
1Column1Column2Column3Column4
2a1d4
3b2e5
4c3f6
5
6
7Column1Column2
8a1
9b2
10c3
11d4
12e5
13f6
Sheet1
 
Upvote 0
You can indeed create a duplicate table. Here another solution.

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    colNames = {{"Column1", "Column2"},{"Column3", "Column4"}},
    FirstTwo = Table.SelectColumns(Source,colNames{0}),
    LastTwo = Table.RenameColumns(Table.SelectColumns(Source,colNames{1}), List.Zip({colNames{1},colNames{0}})),
    result = Table.Combine({FirstTwo,LastTwo})
in
    result


Book1
ABCD
1Column1Column2Column3Column4
2a1d4
3b2e5
4c3f6
5
6
7Column1Column2
8a1
9b2
10c3
11d4
12e5
13f6
Sheet1
Okay thank you for the help! I'll give this code a shot too.
 
Upvote 0

Forum statistics

Threads
1,223,932
Messages
6,175,468
Members
452,646
Latest member
tudou

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