Forum Discussion

ishana's avatar
ishana
Regular Visitor
9 years ago
Solved

Merging 2 rows by splitting one column

Hey! I want to know how can I split my column in the following way  I have data like:               s1  1   2    3                                         s2  1   2    3                           ...
  • v-chuncz-msft's avatar
    9 years ago

    ishana,

     

    You may refer to the following code snippet.

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WKjZUMFQwUjBWitUBcoyQOcYwTiwA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}}),
        #"Split Column by Delimiter" = Table.ExpandListColumn(Table.TransformColumns(#"Changed Type", {{"Column1", Splitter.SplitTextByDelimiter(" ", QuoteStyle.Csv), let itemType = (type nullable text) meta [Serialized.Text = true] in type {itemType}}}), "Column1"),
        #"Removed Duplicates" = Table.Distinct(#"Split Column by Delimiter"),
        #"Sorted Rows" = Table.Sort(#"Removed Duplicates",{{"Column1", Order.Ascending}}),
        #"Transposed Table" = Table.Transpose(#"Sorted Rows")
    in
        #"Transposed Table"