Combiner.CombineTextByPositions
CombinerReturns a combiner function that places text values into fixed positions within a result string, padding as needed.
Syntax
Combiner.CombineTextByPositions(positions as list, optional template as nullable text) as functionParameters
| Name | Type | Required | Description |
|---|---|---|---|
positions | list | Yes | A list of zero-based character positions specifying where each text value should be placed in the output. |
template | text | No | An optional template text used as the base string. If omitted, the output is built from spaces. |
Return Value
function — A 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 | |
|---|---|
| 1 | HelloWorld |
Example 2: Combine with a gap between values
Combiner.CombineTextByPositions({0, 10})({"Hello", "World"})Result | |
|---|---|
| 1 | Hello World |
Example 3: Use with Table.CombineColumns
Table.CombineColumns(
#table({"First", "Last"}, {{"John", "Doe"}}),
{"First", "Last"},
Combiner.CombineTextByPositions({0, 10}),
"FullName"
)FullName | |
|---|---|
| 1 | John Doe |