Text.PositionOfAny
This function will retrieve the index of the first instance of a character from a specified list (characters) within a given text. The optional argument 'occurrence' can be used to choose which specif...
Text.PositionOfAny(text as text, characters as list, optional occurrence as nullable number) as any
This function will retrieve the index of the first instance of a character from a specified list (characters) within a given text. The optional argument 'occurrence' can be used to choose which specific occurrence index to return.
Example 1
Locate the initial occurrence of either "W" or "H" in the text "Hello, World!".
Instructions
Power Query MText.PositionOfAny("Hello, World!", {"H", "W"})
Result
0
Example 2
Identify all occurrences of "W" or "H" in the text "Hello, World!".
Instructions
Power Query MText.PositionOfAny("Hello, World!", {"H", "W"}, Occurrence.All)
Result
{0, 7}