Forum Discussion
Stack and Pivot?
- 5 years ago
Hi Anonymous
It is possible to transform the data into the output you want. Create a blank query and paste below codes into its Advanced editor to see the steps. Or download the attachment at the bottom.
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("hdGtDsJAEEXhVyGra9g/XzozHt1UICoQbAmFEN4eBdnNEWuv+MQ98+zOr3V/XrdyOLrBTdvtfimfcSz7e31UywnL9FuWoUI8EA/EA/EtEoAEIAFIaJEIJAKJQGKLJCAJSAKSWiQDyUAykNwi1fOCForFenUELRSL9eoIWigW69URtFAs1qsjaKFYrFdH0EKx2L/O8gU=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t, Column3 = _t, Column4 = _t]), #"Grouped Rows" = Table.Group(Source, {"Column1"}, {{"AllContent", each _, type table [Column1=nullable text, Column2=nullable text, Column3=nullable text, Column4=nullable text]}}), #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Custom", each List.Combine({[AllContent][Column2], [AllContent][Column3], [AllContent][Column4]})), #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"AllContent"}), #"Extracted Values" = Table.TransformColumns(#"Removed Columns", {"Custom", each Text.Combine(List.Transform(_, Text.From), ";"), type text}), #"Split Column by Delimiter" = Table.SplitColumn(#"Extracted Values", "Custom", Splitter.SplitTextByDelimiter(";", QuoteStyle.Csv), {"Custom.1", "Custom.2", "Custom.3", "Custom.4", "Custom.5", "Custom.6"}), #"Transposed Table" = Table.Transpose(#"Split Column by Delimiter"), #"Promoted Headers" = Table.PromoteHeaders(#"Transposed Table", [PromoteAllScalars=true]) in #"Promoted Headers"Regards,
Community Support Team _ Jing
If this post helps, please Accept it as the solution to help other members find it.
You should consider putting the Company names as the names of columns 2-4 and then unpivoting them, so your table has Company, question, and answer columns. This will set you up for easier analysis/visualization (e.g., put Company column as columns in a matrix visual).
Pat
- Anonymous5 years agoNot applicable
Company Name IS Question1 so Answer1 is the company name in all of these cases.
The challenge with titling that way (if I am understanding your suggestion correctly) is that column 2 contains CompanyA answers (in rows 1-6), and CompanyD answers (in 7-12), and CompanyG answers (though I have removed those for the sake of clarity here, in 13-18). That will probably make more sense if you look closely at the arrangement of the questions and the arrangement of the answers for companies A-F.
The pattern repeats downward a hundred or so times. The pattern is currently three companies wide, but will eventually be 5 or so companies wide (because of the ridiculous way this report is originally formatted).
Does that make any sense?