Forum Discussion
Transpose / Pivot data
- Anonymous3 years ago
Hi Anonymous ,
I have created a simple sample , please refer to my pbix file to see if it helps you.
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("TZE9SwNBEIb/y9UJ7HzvlDYWAbWwDCmScKgQk3DeCf57d2dOsNqFe+ad597d74fd8bocp59hM2AV7AdV4KLt5kbczy2RFaE6HDb74XE8TX8DjtQPdkHnGDCp6wA6cAw8Hafze8SbJm2o0G4AphGwJVAHSvzhPn1cAte0UdUIbUsyvH8B8TU8RShYRrHSEx0USyRzlaYS7G65jgF7WAu2PA6PYlWCFqlSYaUvPZpKgYgWo2KdRtCa1q0TMkrr5W35mjsPJVREikn+Janb6oJtefCv430eP0/jFCOSQooVu0dFYshemM2z95fzfFt5jNfB1gtT54GAPB8KRIvkwPPt+9+GrB4EohesxTG6dBah5nT4BQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Month = _t, Members = _t, #"Sum of Funds" = _t, #"Sum of Adjust" = _t, #"Sum of TotalExp" = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Month", type text}, {"Members", Int64.Type}, {"Sum of Funds", Int64.Type}, {"Sum of Adjust", Int64.Type}, {"Sum of TotalExp", Int64.Type}}), #"Transposed Table" = Table.Transpose(#"Changed Type"), #"Promoted Headers" = Table.PromoteHeaders(#"Transposed Table", [PromoteAllScalars=true]), #"Changed Type1" = Table.TransformColumnTypes(#"Promoted Headers",{{"January", Int64.Type}, {"February", Int64.Type}, {"March", Int64.Type}, {"April", Int64.Type}, {"May", Int64.Type}, {"June", Int64.Type}, {"July", Int64.Type}, {"August", Int64.Type}, {"September", Int64.Type}, {"October", Int64.Type}, {"November", Int64.Type}}), #"Added Index" = Table.AddIndexColumn(#"Changed Type1", "Index", 1, 1, Int64.Type) in #"Added Index"let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8k3NTUotKlaK1YlWCi7NVchPU3ArzUtBEXBMySotLkEWCckvScxxrShQio0FAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Month = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Month", type text}}), #"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 1, 1, Int64.Type) in #"Added Index"let Source = Table.NestedJoin(Table, {"Index"}, #"Table (2)", {"Index"}, "Table (2)", JoinKind.LeftOuter), #"Expanded Table (2)" = Table.ExpandTableColumn(Source, "Table (2)", {"Month"}, {"Month"}), #"Reordered Columns" = Table.ReorderColumns(#"Expanded Table (2)",{"Month", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "Index"}), #"Removed Columns" = Table.RemoveColumns(#"Reordered Columns",{"Index"}) in #"Removed Columns"How to Get Your Question Answered Quickly
If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .
Best Regards
Community Support Team _ PollyIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi Idrissshatila probably the title of my question is not right, the table that I show is the result of a visual, my data table has another structure, as I commented in the text, see below a sample. So, I don't know how transpose my table to get the visual that I need, even I'm not sure if transpose is the solution.
| Member | Date | Fund | Adjust | TotalExp |
| Member1 | 1/25/2022 | 50.1 | 12.45 | -102.8 |
| Member1 | 2/6/2022 | 52.4 | 10.8 | -35.6 |
| Member1 | 3/25/2022 | 80.5 | 15.4 | -40.5 |
| Member2 | 1/8/2022 | 52.4 | 10.8 | -35.6 |
| Member2 | 2/14/2022 | 80.5 | 15.4 | -40.5 |
| Member3 | 3/25/2022 | 50.1 | 12.45 | -102.8 |