Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Split CSV values in a column into multiple rows

Hello,   I'm quite new to DAX. I need your help for transforming a table from somthing like:   Name | Type A  |  f,g B  |  f,i,h C  |  p   into something like:   Name | Type A  |  f A  |...
  • LivioLanzo's avatar
    7 years ago

    Hi Anonymous

     

    you can do it like this:

     

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUUrTSVeK1YlWcgKzM3UywDxnIK9AKTYWAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Name = _t, Type = _t]),
        ChangedType = Table.TransformColumnTypes(Source,{{"Name", type text}, {"Type", type text}}),
        SplitColumnbyDelimiter = Table.ExpandListColumn(Table.TransformColumns(ChangedType, {{"Type", Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv), let itemType = (type nullable text) meta [Serialized.Text = true] in type {itemType}}}), "Type")
    in
        SplitColumnbyDelimiter