Downloads
Power Query MList: transform and filterBeginner

List.Transform

Applies a function to every item in a list and returns a new list of the results.

Syntax
List.Transform(list, transform)

Returns: A list of the same length, with each item replaced by the function's result.

What it does

List.Transform takes each item in a list, runs your function on it, and collects the results in order. Use it when you want the same change applied to every value, such as adding sales tax to a list of amounts or converting text to numbers before you total them. The original list is not changed.

Syntax and arguments

Example

A controller wants invoice amounts with 8 percent sales tax added, as a check on a customer statement. The amounts are already in a list.

let
    Amounts = {100, 250, 1200},
    WithTax = List.Transform(Amounts, each _ * 1.08),
    Rounded = List.Transform(WithTax, each Number.Round(_, 2))
in
    Rounded

The first step multiplies every amount by 1.08. The second rounds each result to cents. The answer is a new list with the same three items, each one 8 percent higher. For a whole table, use Table.TransformColumns instead, which works on a column of rows.

Example: a second, different use

Turning text from a CSV into numbers before any totals. List.Transform({"120.50", "80"}, Number.FromText) returns the numbers 120.5 and 80.

Things to watch

In business terms

Finance teams use List.Transform to apply rates, convert currencies, add tax or fees, or clean text such as stripping a currency symbol before a total. It is the step that comes before a sum, a check or a lookup.

Related functions

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