List.FirstN

If a number is provided, the system will return items up to that specified amount. If a condition is set, all items that meet the condition initially will be returned. However, once an item no longer ...

Syntax

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

About

If a number is provided, the system will return items up to that specified amount. If a condition is set, all items that meet the condition initially will be returned. However, once an item no longer meets the condition, it will be excluded from further consideration.

Explanation

Locate the initial numbers in the set {3, 4, 5, -1, 7, 8, 2} that are above zero. Utilize the Power Query MList.FirstN function with the list {3, 4, 5, -1, 7, 8, 2}, applying the condition that each number is greater than zero. The resulting output will be {3, 4, 5}.