Combiner.CombineTextByLengths

Combiner

Returns a function that combines a list of text values by padding or truncating each to a fixed length.

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

Syntax

Combiner.CombineTextByLengths(lengths as list, optional quoteStyle as nullable number) as function

Parameters

NameTypeRequiredDescription
lengthslistYesA list of integers specifying the fixed width for each text value. Values shorter than their length are padded with spaces; longer values are truncated.
quoteStylenumberNoA QuoteStyle value specifying how to handle quoting. Defaults to QuoteStyle.None.

Return Value

functionA function that takes a list of text values and combines them into a fixed-width string.

Remarks

Combiner.CombineTextByLengths returns a function that produces fixed-width output. Each value in the input list is padded with trailing spaces or truncated to match the corresponding length. This is useful for generating fixed-width file formats or aligning columnar text output.

Examples

Example 1: Create fixed-width output from Sales data

let
    Subset = Table.SelectColumns(Table.FirstN(Sales, 3), {"CustomerName", "Product"}),
    CombinerFn = Combiner.CombineTextByLengths({10, 12}),
    Combined = Table.ToList(Subset, CombinerFn)
in
    #table({"FixedWidth"}, List.Transform(Combined, each {_}))
Result
FixedWidth
1Alice Widget A
2Bob Gadget B
3Charlie Widget C

Compatibility

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