List.PositionOf
This topic applies to the Power Query Formula Language which can be used with Power Query and Power BI Desktop to build queries that mashup data. See the list of function categories.
Finds the first occurrence of a value in a list and returns its position.
List.PositionOf(list as list, value as any, optional occurrence as nullable number,optional equationCriteria as any) as any
| Argument | Description |
|---|---|
| list | The List to check. |
| value | The value to check for. |
| optional occurrence | An enum that controls the scope of operation. |
| optional equationCriteria | An optional equation criteria value to control equality comparisons. For more information about equality comparisons, see Parameter Values. |
| Setting | Description |
|---|---|
| Occurrence.First and Occurrence.Last | Returns a single position. |
| Occurrence.All | Returns a list of positions with all occurrences. |
- If the value is not found in the list, -1 is returned
List.PositionOf({"A", "B", "C", "D"}, "C") equals 2
List.PositionOf({"A", "B", "C", "B", "A"}, "A", Occurrence.First) equals 0
List.PositionOf({"A", "B", "C", "B", "A"}, "A", Occurrence.Last) equals 4
List.PositionOf({"A", "B", "C", "B", "A"}, "A", Occurrence.All) equals {0, 4}
Show: