Combiner.CombineTextByLengths
CombinerReturns a function that combines a list of text values by padding or truncating each to a fixed length.
Syntax
Combiner.CombineTextByLengths(lengths as list, optional quoteStyle as nullable number) as functionParameters
| Name | Type | Required | Description |
|---|---|---|---|
lengths | list | Yes | A list of integers specifying the fixed width for each text value. Values shorter than their length are padded with spaces; longer values are truncated. |
quoteStyle | number | No | A QuoteStyle value specifying how to handle quoting. Defaults to QuoteStyle.None. |
Return Value
function — A 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 | |
|---|---|
| 1 | Alice Widget A |
| 2 | Bob Gadget B |
| 3 | Charlie Widget C |
Compatibility
✓ Power BI Desktop✓ Power BI Service✓ Excel Desktop✓ Excel Online✓ Dataflows✓ Fabric Notebooks