List.Alternate
Every so many items of a list: skip some, keep some, over and over.
Group: List. Power Query M has it too: a query that uses it is written as in Power BI.
Syntax
List.Alternate(list as list, count as number, optional repeatInterval as nullable number, optional offset as nullable number) as list
| Parameter | Type | Description |
|---|---|---|
list | list | The list. |
count | number | How many items to skip each time. |
repeatInterval | nullable number optional | How many items to keep between skips; without it, only the first count items are skipped. |
offset | nullable number optional | How many items to keep at the start before skipping begins. |
Returns
list. The items kept.
Examples
Without the subtotal lines
List.Alternate({"Coffee", "Subtotal", "Tea", "Subtotal", "Milk", "Subtotal"}, 1, 1, 1)
{"Coffee", "Tea", "Milk"}
Skip two, keep three
List.Alternate({1..10}, 2, 3)
{3, 4, 5, 8, 9, 10}