Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.
Hi All,
I have a table as in the 1st Pic and need a 2 column Transpose Table as mentioned in the 2nd pic. Please let me know if power bi has this option of transposing
Solved! Go to Solution.
it is my variant? pls try it
= Table.Combine(
List.Transform( Table.ToRows( #"Changed Type"),
(x)=> Table.FromRows( List.Split(x,2))))
----------------- or--------------
= Table.Combine(
List.Transform( Table.ToRows( #"Changed Type"),
(x)=> Table.FromRows( List.Split(x,2),{"Col1", "Col2"})))
Sample PBIX file attached
https://1drv.ms/u/s!AiUZ0Ws7G26RiHU5B_NG7o0HK6as?e=Xonqvs
hi @VahidDM ,
The above solution worked perfectly as solution. Thanks for help and DXP.
Need one more help please if possible as the table is extended with new columns as below and need help in Transpose multiple columns
Can u please help
I have the table as below :
Table:
Col1 | Col2 | Col3 | Col4 | Col5 | Col6 | Col7 | Col8 |
a1 | a2 | a3 | a4 | a5 | a6 | a7 | a8 |
b1 | b2 | b3 | b4 | b5 | b6 | b7 | b8 |
c1 | c2 | c3 | c4 | c5 | c6 | c7 | c8 |
Result like this:
Col1 | Col2 | Col5 | Col6 |
a1 | a2 | a5 | a6 |
a3 | a4 | a5 | a6 |
a7 | a8 | a5 | a6 |
b1 | b2 | b5 | b6 |
b3 | b4 | b5 | b6 |
b7 | b8 | b5 | b6 |
c1 | c2 | c5 | c6 |
c3 | c4 | c5 | c6 |
c7 | c8 | c5 | c6 |
hi @VahidDM ,
The above solution worked perfectly as solution. Thanks for help and DXP.
Need one more help please if possible as the table is extended with new columns as below and need help in Transpose multiple columns
Can u please help
I have the table as below :
Table:
Col1 | Col2 | Col3 | Col4 | Col5 | Col6 | Col7 | Col8 |
a1 | a2 | a3 | a4 | a5 | a6 | a7 | a8 |
b1 | b2 | b3 | b4 | b5 | b6 | b7 | b8 |
c1 | c2 | c3 | c4 | c5 | c6 | c7 | c8 |
Result like this:
Col1 | Col2 | Col5 | Col6 |
a1 | a2 | a5 | a6 |
a3 | a4 | a5 | a6 |
a7 | a8 | a5 | a6 |
b1 | b2 | b5 | b6 |
b3 | b4 | b5 | b6 |
b7 | b8 | b5 | b6 |
c1 | c2 | c5 | c6 |
c3 | c4 | c5 | c6 |
c7 | c8 | c5 | c6 |
Hi,
Share the actual column titles (rather than Col1-Col8)
Hi all, Thanks for help.. I was able to get the steps to achieve based on above
Hi @VahidDM ,
Please need ur help if the latest request is possible with ur soluttion as i proceeded with ur answer
Hi all,
Thanks a lot for reply. Sorry i should have mentioned this before.. There are extra columns in the Table and that should get replicated . In the below example Col0 and Col5 Values are replicated . Can this be done? please suggest
to understand that it is easy to do, watch my video
https://1drv.ms/v/s!AiUZ0Ws7G26RiHY8BkGK6gF88Urd?e=oGtUsh
Sample PBIX file attached
https://1drv.ms/u/s!AiUZ0Ws7G26RiHfa4iY9me5PwT9B?e=qNfnUT
(r) => Table.Combine(
List.Transform( Table.ToRows(
Table.RemoveColumns(r, {Table.ColumnNames(r){0},Table.ColumnNames(r){5}})),(x)=> Table.FromRows( List.Split(x,2),{"Col1", "Col2"})))
Hi @Ahmedx ,
Thanks fr ur video. Can u please help the same logic for the below data set
2 new columns to be added in the result
NewCol1 | NewCol2 |
Each row should be copied to 2 more rows
NewCol1 values will have class_scheme_node_name,class_scheme_node_name_benchmark ,ExcessReturn Header values
NewCol2 values will have log_portfolio_base, log_benchmark_base and ExcessReturn values
data set
portfolio_code | class_scheme_code | class_scheme_node_name | class_scheme_node_name_benchmark | class_scheme_node_code | date_from | date_to | contribution_base | sequence | return_portfolio_base | log_portfolio_base | log_benchmark_base | log_contribution_base | Excess_Return | ExcessReturnsHeader | client_name | client_type | Portfolio_Node_Name_Override | Benchmark_Node_Name_Override | |
Pool1 | class_scheme_code_11 | ACTIVE ASSET AND FX ALLOCATION | ACTIVE ASSET AND FX ALLOCATION Benchmark | ACTIVE_ASSET_FX_ALLOC | 06/30/2023 | 06/30/2023 | -0.00032 | .000.003.004 | 17.96368 | 0.165207 | 0 | -3.23E-06 | 0.082603 | Excess Returns | client_name1 | Endowment | NULL | NULL | |
Pool1 | class_scheme_code_14 | CASH AND EQUIVALENTS | CASH AND EQUIVALENTS Benchmark | CASHEQ | 06/30/2023 | 06/30/2023 | 0.000529 | .000.000.000.000 | 0.013112 | 0.000131 | 0.007916 | 5.29E-06 | -0.00389 | Excess Returns | client_name4 | Endowment | NULL | NULL |
Result:
NewCol1 | NewCol2 | portfolio_code | class_scheme_code | class_scheme_node_name | class_scheme_node_name_benchmark | class_scheme_node_code | date_from | date_to | contribution_base | sequence | return_portfolio_base | log_portfolio_base | log_benchmark_base | log_contribution_base | Excess_Return | ExcessReturnsHeader | client_name | client_type | Portfolio_Node_Name_Override | Benchmark_Node_Name_Override | |
ACTIVE ASSET AND FX ALLOCATION | 3.23E-06 | Pool1 | class_scheme_code_11 | ACTIVE ASSET AND FX ALLOCATION | ACTIVE ASSET AND FX ALLOCATION Benchmark | ACTIVE_ASSET_FX_ALLOC | 06/30/2023 | 06/30/2023 | -0.00032 | .000.003.004 | 17.96368 | 0.165207 | 2 | 6.46E-06 | 0.082603 | Excess Returns | client_name1 | Endowment | NULL | NULL | |
ACTIVE ASSET AND FX ALLOCATION Benchmark | 2 | Pool1 | class_scheme_code_11 | ACTIVE ASSET AND FX ALLOCATION | ACTIVE ASSET AND FX ALLOCATION Benchmark | ACTIVE_ASSET_FX_ALLOC | 06/30/2023 | 06/30/2023 | -0.00032 | .000.003.004 | 17.96368 | 0.165207 | 2 | -3.23E-06 | 0.082603 | Excess Returns | client_name1 | Endowment | NULL | NULL | |
Excess Returns | 0.082603 | Pool1 | class_scheme_code_11 | ACTIVE ASSET AND FX ALLOCATION | ACTIVE ASSET AND FX ALLOCATION Benchmark | ACTIVE_ASSET_FX_ALLOC | 06/30/2023 | 06/30/2023 | -0.00032 | .000.003.004 | 17.96368 | 0.165207 | 2 | -3.23E-06 | 0.082603 | Excess Returns | client_name1 | Endowment | NULL | NULL | |
CASH AND EQUIVALENTS | 0.000131 | Pool2 | class_scheme_code_14 | CASH AND EQUIVALENTS | CASH AND EQUIVALENTS Benchmark | CASHEQ | 06/30/2023 | 06/30/2023 | 0.000529 | .000.000.000.000 | 0.013112 | 0.000131 | 0.007916 | 5.29E-06 | -0.00389 | Excess Returns | client_name4 | Endowment | NULL | NULL | |
CASH AND EQUIVALENTS Benchmark | 0.007916 | Pool2 | class_scheme_code_14 | CASH AND EQUIVALENTS | CASH AND EQUIVALENTS Benchmark | CASHEQ | 06/30/2023 | 06/30/2023 | 0.000529 | .000.000.000.000 | 0.013112 | 0.000131 | 0.007916 | 5.29E-06 | -0.00389 | Excess Returns | client_name4 | Endowment | NULL | NULL | |
Excess Returns | -0.00389 | Pool2 | class_scheme_code_14 | CASH AND EQUIVALENTS | CASH AND EQUIVALENTS Benchmark | CASHEQ | 06/30/2023 | 06/30/2023 | 0.000529 | .000.000.000.000 | 0.013112 | 0.000131 | 0.007916 | 5.29E-06 | -0.00389 | Excess Returns | client_name4 | Endowment | NULL | NULL |
Hi,
In the second step of my solution, select Col0, Col5 and the Index column and then "Unpivot Other columns".
it is my variant? pls try it
= Table.Combine(
List.Transform( Table.ToRows( #"Changed Type"),
(x)=> Table.FromRows( List.Split(x,2))))
----------------- or--------------
= Table.Combine(
List.Transform( Table.ToRows( #"Changed Type"),
(x)=> Table.FromRows( List.Split(x,2),{"Col1", "Col2"})))
Sample PBIX file attached
https://1drv.ms/u/s!AiUZ0Ws7G26RiHU5B_NG7o0HK6as?e=Xonqvs
Hi,
This M code works
let
Source = Excel.CurrentWorkbook(){[Name="Data"]}[Content],
#"Added Index" = Table.AddIndexColumn(Source, "Index", 1, 1, Int64.Type),
#"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Added Index", {"Index"}, "Attribute", "Value"),
#"Removed Columns" = Table.RemoveColumns(#"Unpivoted Other Columns",{"Attribute"}),
#"Grouped Rows" = Table.ExpandTableColumn(Table.Group(#"Removed Columns", {"Index"}, {{"Count", each Table.AddIndexColumn(_,"Column",1,1), type table }}), "Count", {"Value", "Column"}, {"Value", "Column"}),
#"Calculated Modulo" = Table.TransformColumns(#"Grouped Rows", {{"Column", each Number.Mod(_, 2), type number}}),
#"Grouped Rows1" = Table.ExpandTableColumn(Table.Group(#"Calculated Modulo", {"Column"}, {{"Count", each Table.AddIndexColumn(_,"Row",1,1), type table }}), "Count", {"Index", "Value", "Row"}, {"Index", "Value", "Row"}),
#"Removed Columns1" = Table.RemoveColumns(#"Grouped Rows1",{"Index"}),
#"Sorted Rows" = Table.Sort(#"Removed Columns1",{{"Row", Order.Ascending}, {"Column", Order.Descending}}),
#"Pivoted Column" = Table.Pivot(Table.TransformColumnTypes(#"Sorted Rows", {{"Column", type text}}, "en-IN"), List.Distinct(Table.TransformColumnTypes(#"Sorted Rows", {{"Column", type text}}, "en-IN")[Column]), "Column", "Value"),
#"Removed Columns2" = Table.RemoveColumns(#"Pivoted Column",{"Row"})
in
#"Removed Columns2"
Hope this helps.