<!-- https://learnsql.cpetoday.com/functions/m/list-positions -->
# List.Positions

Language: Power Query M
Category: List: pick and build
Syntax: List.Positions(list)
Summary: Returns the position number of every item in a list, starting from zero.
Returns: A list of whole numbers from 0 up to one less than the count.
Level: Beginner
Related: List.Numbers, List.Range, List.Count, List.Transform, List.Zip

## What it does
List.Positions gives you the index of each item: 0 for the first, 1 for the second, and so on. Use it to number rows, to pair an item with its position, or to build a loop over a list where the position matters. It is the list version of an index column.

## Syntax and arguments
- `list`: the list whose positions you want. Only its length matters.

## Example
A check register is a list of cleared amounts. The auditor wants each line numbered so that a question can refer to line 5 rather than to an amount.

```powerquery
let
    Cleared = {250, 1800, 75, 920},
    Positions = List.Positions(Cleared),
    Numbered = List.Transform(Positions, each "Line " & Text.From(_ + 1) & ": " & Text.From(Cleared{_}))
in
    Numbered
```

`Positions` is {0, 1, 2, 3}. The label adds 1 so that the first line reads "Line 1", and it uses `Cleared{_}` to fetch the amount at that position. The result reads "Line 1: 250" and so on.

## Example: a second, different use
Adding a row number to a table: Table.AddIndexColumn does this for tables, and List.Positions is the list form.

## Things to watch
- Positions start at zero, but people count lines from one. Add 1 when you show a number to a reader.
- The positions are fixed to the list as it is now. If you sort or filter first, the numbers change.
- Looking up an item by position with `list{n}` fails when n is outside the list. Use `list{n}?` to get null instead.
- For a table, Table.AddIndexColumn is the usual way to number rows.

## In business terms
Line numbers on exception reports, sequence checks on invoice or check runs and references in an audit trail all need a stable position. Numbering after the final sort keeps the reference the same as the report the reader sees.
