Text.PositionOfAny

 

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.

Returns the first occurrence of a text value in list and returns its position starting at startOffset.

Text.PositionOfAny(string as text, list as list, optional occurrence as nullable number) as number  

ArgumentDescription
stringThe string to search for.
listThe list to search through.
optional occurrenceAn enum that controls the scope of operation.
SettingDescription
Occurrence.First or Occurrence.LastA single position is returned.
Occurrence.AllA list of positions is returned for all occurrences.
  • If the text values are not found in the list, -1 is returned.
List.PositionOfAny("ABCD", {"B","C"}) equals 1  

List.PositionOfAny("ABCBA", {"A","B"}, Occurrence.First) equals 0  

List.PositionOfAny("ABCBA", {"A","B"}, Occurrence.Last) equals 4  

List.PositionOfAny("ABCBA", {"A","B"}, Occurrence.All) equals {0,1,3,4}  

Show: