Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
HI all,
I am trying to do the opositie from a normal Pivot in Power Query but I cannot get it working. Hope you can help me.
My data looks like this.
Customer Number | Atribute A | Atribute B | Atribute C |
1 | Bottle | Spike | Horse |
1 | Cap | Triangle | Moose |
1 | Water | Round | Duck |
And I need it to look like this:
Customernr | A | B | C | A1 | B1 | C1 | A2 | B2 | C2 |
1 | Bottle | Spike | Horse | Cap | Triangle | Moose | Water | Round | Duck |
My Table contains multiple Customers and a customer can have up to 10 rows which need to be converted into columns. (A10 B10 C10. I Hope you can help me fix this.
Thanx in advance
Solved! Go to Solution.
@BobKoenen , Try this in power Query
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUXLKLynJSQUyggsys0G0R35RcapSrA5E2jmxAEiGFGUm5qWDlfnm5yNJhyeWpBYB6aD80rwUIO1SmpytFBsLAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Customer Number" = _t, #"Atribute A" = _t, #"Atribute B" = _t, #"Atribute C" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Customer Number", Int64.Type}, {"Atribute A", type text}, {"Atribute B", type text}, {"Atribute C", type text}}),
#"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 1, 1, Int64.Type),
#"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Added Index", {"Customer Number", "Index"}, "Attribute", "Value"),
#"Merged Columns" = Table.CombineColumns(Table.TransformColumnTypes(#"Unpivoted Other Columns", {{"Index", type text}}, "en-US"),{"Attribute", "Index"},Combiner.CombineTextByDelimiter(" ", QuoteStyle.None),"Merged"),
#"Pivoted Column" = Table.Pivot(#"Merged Columns", List.Distinct(#"Merged Columns"[Merged]), "Merged", "Value", List.Max)
in
#"Pivoted Column"
@amitchandak
Thankx a lot for replying. Unfortunatly I cannot use an index column because my data is a big table which has more than one customernumber
CustomerNumer | A | B | C |
1111 | Value A | Value B | Value C |
1111 | Value A | Value B | Value C |
1112 | Value A | Value B | Value C |
1113 | Value A | Value B | Value C |
1113 | Value A | Value B | Value C |
1113 | Value A | Value B | Value C |
Is there a way to use the index to count the number of rows from the same customer? Maybe that wil fix it.
@BobKoenen , Try this in power Query
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUXLKLynJSQUyggsys0G0R35RcapSrA5E2jmxAEiGFGUm5qWDlfnm5yNJhyeWpBYB6aD80rwUIO1SmpytFBsLAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Customer Number" = _t, #"Atribute A" = _t, #"Atribute B" = _t, #"Atribute C" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Customer Number", Int64.Type}, {"Atribute A", type text}, {"Atribute B", type text}, {"Atribute C", type text}}),
#"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 1, 1, Int64.Type),
#"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Added Index", {"Customer Number", "Index"}, "Attribute", "Value"),
#"Merged Columns" = Table.CombineColumns(Table.TransformColumnTypes(#"Unpivoted Other Columns", {{"Index", type text}}, "en-US"),{"Attribute", "Index"},Combiner.CombineTextByDelimiter(" ", QuoteStyle.None),"Merged"),
#"Pivoted Column" = Table.Pivot(#"Merged Columns", List.Distinct(#"Merged Columns"[Merged]), "Merged", "Value", List.Max)
in
#"Pivoted Column"
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
110 | |
94 | |
81 | |
66 | |
58 |
User | Count |
---|---|
150 | |
119 | |
104 | |
87 | |
67 |