Combiner.CombineTextByPositions

Combiner

Returns a combiner function that places text values into fixed positions within a result string, padding as needed.

Examples on this page use shared sample tables. View them to understand the input data before reading the examples below.

Syntax

Combiner.CombineTextByPositions(positions as list, optional template as nullable text) as function

Parameters

NameTypeRequiredDescription
positionslistYesA list of zero-based character positions specifying where each text value should be placed in the output.
templatetextNoAn optional template text used as the base string. If omitted, the output is built from spaces.

Return Value

functionA function that accepts a list of text values and places each at the corresponding position in the output.

Remarks

Combiner.CombineTextByPositions is the inverse of Splitter.SplitTextByPositions. It returns a combiner function that, when called with a list of text values, inserts each value at the corresponding zero-based character position in the output string.

The positions list must be in ascending order and its length must match the number of text values provided. Gaps between positions are filled with spaces (or with characters from the template if one is supplied).

This function is primarily used with Table.CombineColumns to merge column values into a fixed-width formatted string.

Examples

Example 1: Combine two values at fixed positions

Combiner.CombineTextByPositions({0, 5})({"Hello", "World"})
Result
Result
1HelloWorld

Example 2: Combine with a gap between values

Combiner.CombineTextByPositions({0, 10})({"Hello", "World"})
Result
Result
1Hello World

Example 3: Use with Table.CombineColumns

Table.CombineColumns(
    #table({"First", "Last"}, {{"John", "Doe"}}),
    {"First", "Last"},
    Combiner.CombineTextByPositions({0, 10}),
    "FullName"
)
Result
FullName
1John Doe

Compatibility

Power BI Desktop Power BI Service Excel Desktop Excel Online Dataflows Fabric Notebooks