List.Transform Function (Power Query M)

List.Transform applies a function to every item in a list and returns a new list with the results. Available in Excel (Power Query), Power BI Desktop, and Power BI Service.

If you want to run the same calculation or change over each value in a list, this is the function you reach for.

Syntax of List.Transform Function

List.Transform(list as list, transform as function) as list

where

  • list (required, list). The list whose items you want to change.
  • transform (required, function). The function applied to each item. It receives one item at a time and returns the new value for that item.

Returns: a new list, the same length as the input, holding the result of the function for each item. An empty list returns an empty list.

In plain terms, you hand it a list and a rule, and it runs that rule on every item and gives you back the changed list.

Example 1: Multiply each number in a list

Take a list of numbers and multiply each one by 10.

let
Source = List.Transform({3, 7, 11, 20}, each _ * 10)
in
Source

Result: 30, 70, 110, 200

The each _ is shorthand for the function, and _ stands for the current item. So each number runs through _ * 10.

Example 2: Uppercase each name

Turn a list of lowercase names into uppercase.

let
Source = List.Transform({"alice", "bob", "carol"}, each Text.Upper(_))
in
Source

Result: ALICE, BOB, CAROL

Text.Upper(_) runs on each name. The function works with any per-item operation, not just math.

Example 3: Build text codes from numbers

Take a list of ID numbers and turn each into a labeled code.

let
Source = List.Transform({101, 102, 103}, each "ID-" & Text.From(_))
in
Source

Result: ID-101, ID-102, ID-103

Each item is converted to text with Text.From(_) and joined to the ID- prefix.

Notice the input was numbers and the output is text, so the type can change. If you need to join columns rather than list items, see how to concatenate in Power Query.

Example 4: Apply a price increase to a table column

A common use is transforming a single column pulled out of a table.

Say you have a PriceList table and you want to raise every price by 10 percent.

Here is the starting data:

ProductPrice
Keyboard40
Monitor250
Mouse18
Webcam60

Pull the Price column into a list, then transform it:

let
Source = Excel.CurrentWorkbook(){[Name="PriceList"]}[Content],
Prices = Source[Price],
Increased = List.Transform(Prices, each _ * 1.1)
in
Increased

Source[Price] gives you a list of the prices, and List.Transform multiplies each by 1.1. This is one of the more practical things you can do once you are getting started with Power Query.

The result is a list of the increased prices:

Result: 44, 275, 19.8, 66

Example 5: Use the explicit function form

The each _ shorthand only gives you one unnamed argument. When you want a named argument or more complex logic, write the function out in full.

Here you grade a list of scores as Pass or Fail.

let
Source = List.Transform({58, 72, 41, 90}, (score) => if score >= 60 then "Pass" else "Fail")
in
Source

Result: Fail, Pass, Fail, Pass

(score) => ... names the current item score, which reads more clearly than _ once the logic gets longer.

Things to keep in mind with List.Transform

  • It is the “map” function. It always returns a new list the same length as the input, with one result per item. It does not filter or remove anything.
  • The function receives one item at a time. Whatever your function returns becomes that position’s value, so the output can be a different type than the input (Example 3).
  • To change values AND drop some, that is two steps. List.Transform only maps. Use List.Select to filter, then transform what remains (or the other way around).

Performance and query folding

List.Transform works on an in-memory list, so it does not fold to the source. Pull the data you need into the list first, then transform it.

Common questions about List.Transform

What is the difference between List.Transform and List.Select?

List.Transform changes every item and keeps them all, returning a same-length list. List.Select keeps the input values unchanged and returns only the items that pass a condition, so it can be shorter. For other list operations like reducing a column to one value, see how to find the maximum value in a column in Power Query.

Should I use List.Transform or Table.TransformColumns to change a table column?

When you are already working with a table, Table.TransformColumns edits a column in place and keeps the table shape. Reach for List.Transform when you have an actual list, or when you have deliberately extracted a column into one (Example 4).

List of All Power Query Functions

Related Power Query Functions / Articles:

I am a huge fan of Microsoft Excel and love sharing my knowledge through articles and tutorials. I work as a business analyst and use Microsoft Excel extensively in my daily tasks. My aim is to help you unleash the full potential of Excel and become a data-slaying wizard yourself.