Text.PositionOf

 

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 substring in a string and returns its position starting at startOffset.

Text.PositionOf(string as nullable text, substring as text, optional occurrence as nullable number, optional comparer as nullable function) as nullable number  

ArgumentDescription
stringThe text to parse.
substringThe text to string to search for.
optional occurrenceAn enum that controls the scope of operation.
optional comparerThe optional culture aware comparer function can be provided.
SettingDescription
Occurrence.First or Occurrence.LastA single position is returned.
Occurrence.AllA list of positions is returned for all occurrences.
  • If a text value is not found, -1 is returned.
Text.PositionOf("ABCD", "C") equals 2  

Text.PositionOf("ABCBA", "A", Occurrence.First) equals 0  

Text.PositionOf("ABCBA", "A", Occurrence.Last) equals 4  

Text.PositionOf("ABCBA", "A", Occurrence.All) equals {0,4}  

Show: