Text.PositionOfAny Function in Power Query
The Text.PositionOfAny function in Power Query returns the first position in the text value of any listed character (-1 if not found).
Syntax
Text.PositionOfAny( text as text, characters as list, optional occurrence as nullable number ) as any
The function has the following parameters:
- text: The text to search in.
- characters: A list of characters or strings to search for.
- occurrence: It is an optional parameter. It may be used to specify which occurrence position to return. Can be:
- 0 (or omitted): Find the first occurrence.
- 1: Find the last occurrence.
Example: Characters not found in the text.
Power Query M
let Source = Text.PositionOfAny("Ashish Coder", {"S", "R"}) in Source
The output of the above code is -1.
Example: Characters found in the text.
Power Query M
let Source = Text.PositionOfAny("Ashish Coder", {"i", "r"}) in Source
The output of the above code is 3.