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
| Argument | Description |
|---|---|
| string | The string to search for. |
| list | The list to search through. |
| optional occurrence | An enum that controls the scope of operation. |
| Setting | Description |
|---|---|
| Occurrence.First or Occurrence.Last | A single position is returned. |
| Occurrence.All | A 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: