Table of contents
TOC
Collapse the table of content
Expand the table of content

List.PositionOf

Owen Duncan|Last Updated: 4/19/2018

About

Finds the first occurrence of a value in a list and returns its position.

List.PositionOf(list as list, value as any, optional occurrence as nullable number,optional equationCriteria as any) as any  

Arguments

ArgumentDescription
listThe List to check.
valueThe value to check for.
optional occurrenceAn enum that controls the scope of operation.
optional equationCriteriaAn optional equation criteria value to control equality comparisons. For more information about equality comparisons, see Parameter Values.

Occurrence settings

SettingDescription
Occurrence.First and Occurrence.LastReturns a single position.
Occurrence.AllReturns a list of positions with all occurrences.

Remarks

  • If the value is not found in the list, -1 is returned

Examples

List.PositionOf({"A", "B", "C", "D"}, "C") equals 2  
List.PositionOf({"A", "B", "C", "B", "A"}, "A", Occurrence.First)  equals 0  
List.PositionOf({"A", "B", "C", "B", "A"}, "A", Occurrence.Last) equals 4  
List.PositionOf({"A", "B", "C", "B", "A"}, "A", Occurrence.All) equals {0, 4}  
© 2018 Microsoft