Forum Discussion
wad11656
Advocate I
3 years agoText.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...
- 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
ImkeF
Community Champion
3 years agoOr 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