Occurrence.First

Updated on

Occurrence.First (0) is an enumeration that specifies the occurrence of an element in a sequence. It is a member of the Occurrence.Type and indicates the position of the first occurrence of the found value.

Examples

Let’s look at an example using the Occurrence.Last enumeration. The List.PositionOf function supports an optional Occurrence Type. You can enter the Occurrence.First enumeration in the third argument, or write the shorthand value 0. When unspecified the function defaults to using Occurrence.First.

// All three statements return 0
= List.PositionOf( { "ape", "duck", "ape", "cow" },  "ape"  ) 
= List.PositionOf( { "ape", "duck", "ape", "cow" },  "ape", Occurrence.First )
= List.PositionOf( { "ape", "duck", "ape", "cow" },  "ape", 0 ) 

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

// All three statements return 3
= Text.PositionOf( "We all want pasta", "a" ) 
= Text.PositionOf( "We all want pasta", "a", Occurrence.First ) 
= Text.PositionOf( "We all want pasta", "a", 0 ) 

Other related enumerations are:

Applies to

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

Contribute » | Contributors: Rick de Groot

2023-2024 © BI Gorilla. All rights are reserved. Information from Microsoft docs is property of Microsoft Corp. | Privacy Policy