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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

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
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors
Top Kudoed Authors