Downloads
Power Query MTable: build and convertIntermediate

Table.ToList

Joins each row into one text value, using a combiner you choose, and returns the list of those values.

Syntax
Table.ToList(table as table, optional combiner as nullable function) as list

Returns: A list of text values, one for each row.

What it does

Table.ToList gives each row as one piece of text. The combiner sets how the values in the row are joined, such as with a comma or a bar. The result is a list of lines, which can be written to a file, pasted into an email or joined into a single paragraph with Text.Combine.

Syntax and arguments

Example

A list of open items is turned into one line of text for each item, so the lines can be pasted into a note to the controller.

let
    Source = Excel.CurrentWorkbook(){[Name = "OpenItems"]}[Content],
    AsText = Table.TransformColumnTypes(Source, {{"Vendor", type text}, {"Reference", type text}, {"Status", type text}}),
    Lines = Table.ToList(AsText, Combiner.CombineTextByDelimiter(" | "))
in
    Lines

Each row becomes a line such as a vendor, a reference and a status, separated by a bar. The text columns are set first, so the combiner can join them.

Example: a second, different use

The lines are joined into one paragraph for a status note, separated by semicolons.

let
    Source = Excel.CurrentWorkbook(){[Name = "OpenItems"]}[Content],
    AsText = Table.TransformColumnTypes(Source, {{"Vendor", type text}, {"Status", type text}}),
    Lines = Table.ToList(AsText, Combiner.CombineTextByDelimiter(": ")),
    Paragraph = Text.Combine(Lines, "; ")
in
    Paragraph

Things to watch

In business terms

Status notes, memo lines and text for an email are often built from a table of open items. Doing it in the query keeps the wording the same every time, and the text can be checked against the table.

Related functions

All Power Query M functions · View as Markdown · M basics