Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
wad11656
Advocate I
Advocate I

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([#"NamesColumn"]," || "), type text}

 

So instead of a result like:

Betty || Mark || John || Alice

 

I'd like something like:

(1) Betty (2) Mark (3) John (4) Alice

 

1 ACCEPTED SOLUTION
ImkeF
Community Champion
Community Champion

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

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

View solution in original post

2 REPLIES 2
ImkeF
Community Champion
Community Champion

Or if you prefer a solution that does more in table-mode, you could use this:

let
  Source = {"Betty", "Mark", "John", "Alice"}, 
  #"Converted to Table" = Table.FromList(
    Source, 
    Splitter.SplitByNothing(), 
    null, 
    null, 
    ExtraValues.Error
  ), 
  #"Added Index" = Table.AddIndexColumn(#"Converted to Table", "Index", 1, 1, Int64.Type), 
  #"Reordered Columns" = Table.ReorderColumns(#"Added Index", {"Index", "Column1"}), 
  Custom1 = #"Reordered Columns", 
  AddBrackets = Table.TransformColumns(
    Table.TransformColumnTypes(Custom1, {{"Index", type text}}, "en-US"), 
    {{"Index", each "(" & _ & ")", type text}}
  ), 
  Custom2 = AddBrackets, 
  Custom3 = List.Combine(Table.ToRows(Custom2)), 
  Custom4 = Text.Combine(Custom3, " ")
in
  Custom4

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

ImkeF
Community Champion
Community Champion

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

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.