Excel Column-to-row transposition on a multi-row header Excel file
In the following Excel worksheet, A3:F6 is a typical table with column headers, though there are another two rows of headers above:
A |
B |
C |
D |
E |
F |
|
1 |
Actuals |
Actuals |
Plan |
Plan |
||
2 |
FY20 |
FY21 |
FY20 |
FY21 |
||
3 |
Country |
Owner |
1/1/2020 |
1/1/2020 |
1/1/2020 |
1/1/2020 |
4 |
France |
Richard |
100 |
150 |
80 |
160 |
5 |
France |
Martin |
120 |
140 |
130 |
140 |
6 |
France |
Pierre |
50 |
100 |
50 |
80 |
The task is to transpose columns to rows, including both the typical table with header and the extra two rows of headers:
A |
B |
C |
D |
E |
F |
|
9 |
Country |
Owner |
Version |
Year |
Date |
Value |
10 |
France |
Richard |
Actuals |
FY20 |
1/1/2020 |
100 |
11 |
France |
Richard |
Actuals |
FY21 |
1/1/2020 |
150 |
12 |
France |
Richard |
Plan |
FY20 |
1/1/2020 |
80 |
13 |
France |
Richard |
Plan |
FY21 |
1/1/2020 |
160 |
14 |
France |
Martin |
Actuals |
FY20 |
1/1/2020 |
120 |
15 |
France |
Martin |
Actuals |
FY21 |
1/1/2020 |
140 |
16 |
France |
Martin |
Plan |
FY20 |
1/1/2020 |
130 |
17 |
France |
Martin |
Plan |
FY21 |
1/1/2020 |
140 |
18 |
France |
Pierre |
Actuals |
FY20 |
1/1/2020 |
50 |
19 |
France |
Pierre |
Actuals |
FY21 |
1/1/2020 |
100 |
20 |
France |
Pierre |
Plan |
FY20 |
1/1/2020 |
50 |
21 |
France |
Pierre |
Plan |
FY21 |
1/1/2020 |
80 |
Use SPL XLL to enter the following formula:
=spl("=c=transpose(?2),?1.conj( (a=~).m(3:).(a.to(2)|c(#)|~))",A4:F6,C1:F3)
The transpose()function performs transposition on headers within C1:F3; conj() function concatenates members of the set, where ~ represents each row in table A4:F6; m(3:) means getting members of each row from the 3rd to the end.
SPL Official Website 👉 https://www.scudata.com
SPL Feedback and Help 👉 https://www.reddit.com/r/esProc_Desktop/
SPL Learning Material 👉 https://c.scudata.com
Discord 👉 https://discord.gg/cFTcUNs7
Youtube 👉 https://www.youtube.com/@esProcDesktop
Linkedin Group 👉 https://www.linkedin.com/groups/14419406/