Forum Discussion

JMST's avatar
JMST
Frequent Visitor
2 years ago
Solved

How to transform one column with grouped data in columns

Hi, I have the following information charged in Power BI:  The first column, contains the source filename, and the second one, contains data for several machines, each 10 lines correspond to ...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi,

    Thanks for the solution lbendlin offered, and i want to offer some more information for user to refer to.

    hello JMST , you cna create a blank query  and put the following code to advanced editor in power query.

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSlTSUQpOTszLS01RitVB4Svk5yl4leYoWOgoGBkYmSgYGFsByQBfuDrfxOSMzLxUQ7hARESEHhhFwIVyMvNKK0pKK+ACQUCDPRJLFFzzSlKLCooyi1MVfEBqFIJTi8pSixTM9Szhaovy80vgHIRwgJMznG2kkJtflIru9MHpFYTpZggzPMzhbEOoX2IB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Name = _t, Datos = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"Name", type text}, {"Datos", type text}}),
        #"Grouped Rows1" = Table.Group(#"Changed Type", {"Name"}, {{"Content", each List.Transform(List.Split(_[Datos],10),each Text.Combine(_,"/")),type list}}),
        #"Expanded Content" = Table.ExpandListColumn(#"Grouped Rows1", "Content"),
        #"Split Column by Delimiter" = Table.SplitColumn(#"Expanded Content", "Content", Splitter.SplitTextByDelimiter("/", QuoteStyle.Csv), {"Content.1", "Content.2", "Content.3", "Content.4", "Content.5", "Content.6", "Content.7", "Content.8", "Content.9", "Content.10"}),
        #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Content.1", type text}, {"Content.2", type text}, {"Content.3", type text}, {"Content.4", type text}, {"Content.5", type text}, {"Content.6", type text}, {"Content.7", type text}, {"Content.8", Int64.Type}, {"Content.9", type text}, {"Content.10", type text}})
    in
        #"Changed Type1"

    Output

    Best Regards!

    Yolo Zhu

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.