JackDanIce
Well-known Member
- Joined
- Feb 3, 2010
- Messages
- 9,922
- Office Version
- 365
- Platform
- Windows
Hi,
I have the table on the left in PQ and wish to output the table on the right:
The text before " Class" is always unique (i.e. always a pair of columns {A and A Class}, {B and B Class} etc) and I wish to combine them into single columns with a delimiter to separate, like the table on the right.
Unfortunately, the number of columns is dynamic so not keen to hardcode this.
So far I can do this for a single pair of columns as:
Any suggestions please?
TIA,
Jack
I have the table on the left in PQ and wish to output the table on the right:
Table in PowerQuery | Desired Output | |||||||
Student | E | E Class | F | F Class | Student | E Class | F Class | |
A | 0 | < | 8 | <<< | A | 0 | < | 8 | <<< | |
B | 1 | < | 9 | <<<< | B | 1 | < | 9 | <<<< | |
C | 2 | < | 10 | <<<< | C | 2 | < | 10 | <<<< | |
D | 3 | << | 0 | < | D | 3 | << | 0 | < | |
E | 4 | << | 1 | < | E | 4 | << | 1 | < | |
F | 5 | << | 2 | < | F | 5 | << | 2 | < | |
G | 6 | <<< | 3 | << | G | 6 | <<< | 3 | << | |
H | 7 | <<< | 4 | << | H | 7 | <<< | 4 | << | |
I | 8 | <<< | 5 | << | I | 8 | <<< | 5 | << | |
J | 9 | <<<< | 6 | <<< | J | 9 | <<<< | 6 | <<< | |
K | 10 | <<<< | 7 | <<< | K | 10 | <<<< | 7 | <<< | |
The text before " Class" is always unique (i.e. always a pair of columns {A and A Class}, {B and B Class} etc) and I wish to combine them into single columns with a delimiter to separate, like the table on the right.
Unfortunately, the number of columns is dynamic so not keen to hardcode this.
So far I can do this for a single pair of columns as:
Power Query:
#"Add A Class" = Table.RenameColumns(Table.RemoveColumns(Table.AddColumn(Source, "A Class1", each Number.ToText([A] & " | " & [A Class]), {"A", "A Class"}), {{"A Class1", "A Class"}})
Any suggestions please?
TIA,
Jack