List.FirstN

About

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

Syntax

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

Arguments

Argument Description
list The List to check.
countOrCondition The 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}