List.Alternate Function in Power Query
The List.Alternate function returns a new list with the items from the original list after skipping the specific count of items at each interval.
1. List.Alternate(list as list, skipcount as number) as list Here the List.Alternate function returns a list after skipping the first number of items as specified by the skipcount from the original list.
2. List.Alternate(list as list, skipcount as number, optional repeatInterval as nullable number) as list Here the List.Alternate function returns a list after skipping the first number of items and then returned the specified number of items and repeat the same till the end of the list.
3. List.Alternate(list as list, skipcount as number, optional repeatInterval as nullable number, optional offset as nullable number) as list Here the List.Alternate function returns a list after skipping the first number of items and then returned the specified number of items and repeat the same till the end of the list. Here the process starts after an initial offset which given by the fourth argument.
Example: Create a list after skipping the first two values.
Power Query M
let source = {"India", "America", "Canada", "Japan", "Australia", "England"}, return = List.Alternate(source, 2) in return
The output of the above code is shown below:
Example: Create a list by skipping two items and then returned one item and repeat the same.
Power Query M
let source = {"India", "America", "Canada", "Japan", "Australia", "England"}, return = List.Alternate(source, 2, 1) in return
The output of the above code is shown below:
Example: Create a list by skipping two items and then returned one item and repeat the same, after offset of the one item.
Power Query M
let source = {"India", "America", "Canada", "Japan", "Australia", "England"}, return = List.Alternate(source, 2, 1, 1) in return
The output of the above code is shown below: