Forum Discussion
How to Transpose Columns in a table
Hi Friends
This is Nagarjuna. I Have a small query, Can u please help me on this?
I was created the below table in Power BI
| Column A Sum | Column B Sum | Column C Sum | Column D Sum | Column E Sum | Column F Sum | Column G Sum | Column H Sum |
| 100 | 200 | 150 | 180 | 210 | 220 | 230 | 250 |
I want to transpose the above table. i.e i need the table like the below one
| Column A Sum | 100 |
| Column B Sum | 200 |
| Column C Sum | 150 |
| Column D Sum | 180 |
| Column E Sum | 210 |
| Column F Sum | 220 |
| Column G Sum | 230 |
| Column H Sum | 250 |
And i need the graph like below one
How this possible in power BI
Thanks in Advance
Regards
Nagarjuna
2 Replies
- v-huizhn-msftMicrosoft Employee
Hi Nagarjunav,
I reproduce your scenario and get expected result, please follow the steps below.
1. Right click your sample table->Edit Query, select all columns-> click unpivot columns(lighted in yellow)->click "Apply" on home page. You will transpose columns in the table.
Here is my Power Query statement.let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjQwUNJRMgKThqZg0gIsYggmjcCkMZgEysbGAgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [#"Column A Sum" = _t, #"Column B Sum" = _t, #"Column C Sum" = _t, #"Column D Sum" = _t, #"Column E Sum" = _t, #"Column F Sum" = _t, #"Column G Sum" = _t, #"Column H Sum" = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column A Sum", Int64.Type}, {"Column B Sum", Int64.Type}, {"Column C Sum", Int64.Type}, {"Column D Sum", Int64.Type}, {"Column E Sum", Int64.Type}, {"Column F Sum", Int64.Type}, {"Column G Sum", Int64.Type}, {"Column H Sum", Int64.Type}}), #"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Changed Type", {}, "Attribute", "Value") in #"Unpivoted Columns"
2. You can line chart, select "Attribute" as x-axis, value as value, you will get expected result.
Best Regards,
Angelia- NagarjunavFrequent Visitor
Thanks for your reply v-huizhn-msft
What i posted was not my raw-data, those columns are the calculated columns. I Have 30 columns raw-data and 100 calculated columns.
I am changing my sample data for better understanding.
Here first 3 columns are Raw-data columns, 4th column onwards calculated ones
Transaction ID Supplier Name Amount Amount <250 250<=Amount < 450 450<=Amount < 650 650<=Amount < 850 850<=Amount < 1050 1050<=Amount < 1250 1250<=Amount < 1450 Amount >1450 1 A 100 100 2 B 200 200 3 C 300 300 4 D 400 400 5 E 500 500 6 F 600 600 7 G 700 700 8 H 800 800 9 B 900 900 10 E 1000 1000 11 H 1100 1100 12 F 1200 1200 13 C 1300 1300 14 A 1400 1400 15 E 1500 1500 Now i need the table like below one
Range Amount Amount <250 300 250<=Amount < 450 700 450<=Amount < 650 1100 650<=Amount < 850 1500 850<=Amount < 1050 1900 1050<=Amount < 1250 2300 1250<=Amount < 1450 2700 Amount >1450 1500 If the table comes like this, automatically we can draw the required graph
i.e.
Thanks in advance
Regards
Nagarjuna