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...

Syntax

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

About

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.

Explanation

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}