Forum Discussion

fox252's avatar
fox252
Frequent Visitor
4 years ago
Solved

Group By: Flatten single text data element with delimiter separator

Hello,   I thought I had figured this out once before however I'm stumped... I have data that looks something like this   Financial Acct Detail Acct Value Payable Trade 5 Payable FX...
  • ImkeF's avatar
    4 years ago

    Hi  fox252 ,
    yes, "All Rows" is the way to go. You can add a column with this formula then to retrieve the concatenated fields:

    Text.Combine([All][Detail Acct], ", ")



    Please check out this solution:

     

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCkisTEzKSVXSUQopSkwB0aZKsTrI4m4RQMLQACwalJqcmlmGpsHQ0BCiJTUvJTMvHaTFE0gYGaCJuhaWZpZUgmRM0WRcUouAppZkloHtB+qLBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Financial Acct" = _t, #"Detail Acct" = _t, Value = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"Financial Acct", type text}, {"Detail Acct", type text}, {"Value", Int64.Type}}),
        #"Grouped Rows" = Table.Group(#"Changed Type", {"Financial Acct"}, {{"SumValue", each List.Sum([Value]), type nullable number}, {"All", each _, type table [Financial Acct=nullable text, Detail Acct=nullable text, Value=nullable number]}}),
        #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Detail Account", each Text.Combine([All][Detail Acct], ", ")),
        #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"All"})
    in
        #"Removed Columns"