List.Positions

List

Returns a list of zero-based index positions for all elements in the given list.

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

Syntax

List.Positions(list as list) as list

Parameters

NameTypeRequiredDescription
listlistYesThe list whose positions are to be returned.

Return Value

listA list of integers {0, 1, 2, ...} with one entry per element in the source list.

Remarks

List.Positions returns a list of zero-based integer indices, one for each element in the input list. For a list of length N, it returns {0, 1, 2, ..., N-1}. It is equivalent to List.Numbers(0, List.Count(list)).

The primary use case is enabling index-aware iteration: by combining the positions list with the original list using List.Zip, you get {{0, item0}, {1, item1}, ...} pairs that let you know each item's position during a transform. This is the standard M pattern for "transform with index" — something that has no built-in direct syntax.

For an empty list, returns an empty list {}. The result is always consecutive integers starting at 0. If you need indices starting at 1, use List.Transform(List.Positions(list), each _ + 1) or List.Numbers(1, List.Count(list)).

Examples

Example 1: Get positions of a list

List.Positions({"A", "B", "C", "D"})
Result
Result
1{0, 1, 2, 3}

Example 2: Pair each item with its index using List.Zip

let
    Items = {"Alpha", "Beta", "Gamma"},
    Indexed = List.Zip({List.Positions(Items), Items})
in
    Indexed
Applied Steps

The final output — a list of {position, item} pairs for each element in Items.

Result
1{{0, Alpha}, {1, Beta}, {2, Gamma}}

Example 3: Filter items by even index positions

let
    Items = {"A", "B", "C", "D", "E", "F"},
    Positions = List.Positions(Items),
    EvenIndexItems = List.Transform(
        List.Select(Positions, each Number.Mod(_, 2) = 0),
        each Items{_}
    )
in
    EvenIndexItems
Applied Steps

The final output — a list containing only the items at even index positions from the original list.

Result
1{A, C, E}

Compatibility

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