List.RemoveLastN
This function retrieves a list with elements removed from the end, based on a specified count or condition. If the list contains fewer elements than the specified count or condition, an empty list is ...
This function retrieves a list with elements removed from the end, based on a specified count or condition. If the list contains fewer elements than the specified count or condition, an empty list is returned. When a numeric value is provided, that many items are removed. In the case of a condition, the returned list stops at the first element from the bottom that meets the criteria. Subsequent elements are no longer considered once a condition is not met. If this parameter is left empty, only one item is removed from the list.
Generate a list starting from {1, 2, 3, 4, 5} excluding the last three numbers.
Usage:
Power Query MList.RemoveLastN({1, 2, 3, 4, 5}, 3)
Output:
{1, 2}
Create a list from {5, 4, 2, 6, 4} that concludes with a number below 3.
Usage:
Power Query MList.RemoveLastN({5, 4, 2, 6, 4}, each _ > 3)
Output:
{5, 4, 2}