Forum Discussion

wad11656's avatar
wad11656
Advocate I
3 years ago
Solved

Text.Combine() with incrementing (numerical) delimiter

Is there a way to make Text.Combine() use an incrementing delimiter?   For example, change the "||" below to an incrementing number that starts from 1? {"NamesColumn (Combined)", each Text.Combine...
  • ImkeF's avatar
    3 years ago

    Hi wad11656 ,
    yes, this can be done with the List.Zip-function:

    let
      Source                   = {"Betty", "Mark", "John", "Alice"}, 
      ListWithNumbers          = {1 .. List.Count(Source)}, 
      FormattedListWithNumbers = List.Transform(ListWithNumbers, each "(" & Text.From(_) & ") "), 
      ZipAndExpand             = List.Combine(List.Zip({FormattedListWithNumbers, Source})), 
      ToText                   = Text.Combine(ZipAndExpand, " ")
    in
      ToText