List.RemoveFirstN
ListRemoves the first N items from a list, or items from the start while a condition is true.
Syntax
List.RemoveFirstN(list as list, countOrCondition as any) as listParameters
| Name | Type | Required | Description |
|---|---|---|---|
list | list | Yes | The source list. |
countOrCondition | any | Yes | A number specifying how many items to remove from the start, or a condition function that removes items while it returns true. |
Return Value
list — A new list with the first N items removed.
Remarks
List.RemoveFirstN removes items from the beginning of a list and returns the remainder. It is functionally identical to List.Skip — the two functions behave the same way. Use whichever name makes your intent clearer in context.
When passed a number N, it removes the first N items. If N is larger than the list length, an empty list is returned. When passed a condition function, it removes items from the start while the condition returns true, stopping permanently at the first item that fails — subsequent items that would satisfy the condition are not removed.
This function does not modify the original list; it returns a new list. For removing from the end, use List.RemoveLastN. For removing a block from the middle, use List.RemoveRange. For removing items by value rather than position, use List.RemoveMatchingItems or List.Select with a negated condition.
Examples
Example 2: Remove items while value is less than 30
List.RemoveFirstN({10, 20, 30, 40, 50}, each _ < 30)Result | |
|---|---|
| 1 | {30, 40, 50} |
Example 3: Skip header-like rows (remove first 3)
let
Rows = {"Header", "Subtitle", "---", "Data1", "Data2", "Data3"},
DataOnly = List.RemoveFirstN(Rows, 3)
in
DataOnlyThe final output — the list with the 3 header rows stripped away, containing only the data entries.
Result | |
|---|---|
| 1 | {Data1, Data2, Data3} |