List.PositionOf Function in Power Query

The List.PositionOf function finds the first occurrence of a given value in the input list and returns its index position.

Note: • The index of the first item in the list is 0.
• Returns -1 if the value doesn't appear in the list.

Syntax

List.PositionOf(list as list, value as any, optional occurrence as nullable number, optional equationCriteria as any) as any

Example: Find the index position of “Australia” in the given list.

Power Query M

let
  source = {"India", "America", "Canada", "Japan", "Australia", "England"}, 
  return = List.PositionOf(source, "Australia")
in
  return  

The output of the above code is 4.

Example: Find the index position of “australia” in the given list. The input value is case sensitive. And if the value is not found in the list it will return -1.

Power Query M

let
  source = {"India", "America", "Canada", "Japan", "Australia", "England"}, 
  return = List.PositionOf(source, "australia")
in
  return  

The output of the above code is -1.