List.RemoveFirstN
This function returns a modified list with the first element removed. If the original list is empty, an empty list will be returned. Additionally, this function can take an optional parameter called c...
This function returns a modified list with the first element removed. If the original list is empty, an empty list will be returned. Additionally, this function can take an optional parameter called countOrCondition, which allows for the removal of multiple values in different ways:
- If a number is provided, the function will remove up to that many items from the list.
- If a condition is provided, the returned list will start with the first element that meets the criteria. The function will stop considering elements once one fails the condition.
If the countOrCondition parameter is left blank, the function will follow its default behavior.
Generate a new list by excluding the initial three numbers from the set {1, 2, 3, 4, 5}.
Syntax used:
Power Query MList.RemoveFirstN({1, 2, 3, 4, 5}, 3)
Result:
{4, 5}
Create a list from {5, 4, 2, 6, 1} that begins with a number lower than 3.
Syntax used:
Power Query MList.RemoveFirstN({5, 4, 2, 6, 1}, each _ > 3)
Result:
{2, 6, 1}