Home > Enterprise >  How do I concatenate the values of the inner lists of a nested list in Power Query?
How do I concatenate the values of the inner lists of a nested list in Power Query?

Time:12-10

Starting with this list of N child lists:

{{"value", ".", "1"}, {"value", ".", "2"}, {"value", ".", "3"}}

My desired result is a list of the concatenated items of the child lists:

{"value.1", "value.2", "value.3"}

I have found 1 solution, but I feel it is not as elegant as it could be.

let
    Source = {{"value", ".", "1"}, {"value", ".", "2"}, {"value", ".", "3"}},
    #"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    #"Extracted Values" = Table.TransformColumns(#"Converted to Table", {"Column1", each Text.Combine(List.Transform(_, Text.From)), type text}),
    Column1 = #"Extracted Values"[Column1]
in
    Column1

Is there a better, simpler way to accomplish this without converting to a table and back again?

CodePudding user response:

How about

= List.Transform(Source, each Text.Combine(_))

like

let Source =  {{"value", ".", "1"}, {"value", ".", "2"}, {"value", ".", "3"}},
x=List.Transform(Source, each Text.Combine(_))
in x

or if some of the list is numerical

let Source =  {{"value", ".", 1}, {"value", ".", 2}, {"value", ".", 3}},
x=List.Transform(Source, each Text.Combine(List.Transform(_, each Text.From(_)))) 
in x
  • Related