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

List.FirstN

Owen Duncan|Last Updated: 4/19/2018

About

Returns the first set of items in the list by specifying how many items to return or a qualifying condition provided by countOrCondition.

List.FirstN(list as list, countOrCondition as any) as any  

Arguments

ArgumentDescription
listThe List to check.
countOrConditionThe number or condition to qualify against.

Remarks

  • If a number is specified, up to that many items are returned.

  • If a condition is specified as a function, all items are returned that initially meet the condition.

  • Once an item fails the condition, no further items are considered.

Examples

List.FirstN({3, 4, 5, -1, 7, 8, 2}, 2) equals {3, 4}  
List.FirstN({3, 4, 5, -1 ,7, 8, 2}, each_ > 2) equals {3, 4, 5}  
© 2018 Microsoft