Occurrence.All (2) is an enumeration that specifies the occurrence of an element in a sequence. It is a member of the Occurrence.Type and specifies that a list of positions of all occurrences of the found values is returned.


Let’s look at an example using the Occurrence.All enumeration.

The List.PositionOf function supports an optional Occurrence Type. You can enter the Occurrence.All enumeration in the third argument, or write the shorthand value 2.

// Below statements return a list all matching index-positions: { 0, 2 }
= List.PositionOf( { "ape", "duck", "ape", "cow" },  "ape", Occurrence.All)
= List.PositionOf( { "ape", "duck", "ape", "cow" },  "ape", 2 ) 

The Text.PositionOf function also supports the optional occurrence parameter and shows similar behavior.

// Below statements return a list all matching index-positions: { 3, 8, 13, 16 }
= Text.PositionOf( "We all want pasta", "a", Occurrence.All) 
= Text.PositionOf( "We all want pasta", "a", 2 ) 

Other related enumerations are:

Applies to

Here’s a list of functions that work with Occurrence.Type:

BI Gorilla Youtube Channel

Last update: August 17, 2023 | Contribute » | Contributors: Rick de Groot
© 2023 BI Gorilla. All rights reserved. Content derived from Microsoft documentation is property of Microsoft Corp.