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  

ArgumentDescription
listThe List to check.
valueThe value to check for.
optional occurrenceAn enum that controls the scope of operation.
optional equationCriteriaAn optional equation criteria value to control equality comparisons. For more information about equality comparisons, see Parameter Values.
SettingDescription
Occurrence.First and Occurrence.LastReturns a single position.
Occurrence.AllReturns 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: