Table.AlternateRows Function in Power Query
The Table.AlternateRows function returns a table containing the initial offset and an alternating pattern of the rows from a table.
Syntax
Table.AlternateRows(table as table, offset as number, skip as number, take as number) as table
The function has the following parameters:
- table: It specifies the input table.
- offset: It specifies the number of rows to keep before starting iterations.
- skip: It specifies the number of rows to remove in each iteration.
- take: It specifies the number of rows to keep in each iteration.
Example:
Power Query M
let MyTable = Table.FromRecords( { [CustomerID = 1, Name = "Ashish", Marks = 568], [CustomerID = 2, Name = "Katrina", Marks = 855], [CustomerID = 3, Name = "Alia", Marks = 380], [CustomerID = 4, Name = "Vicky", Marks = 458], [CustomerID = 5, Name = "Mohini", Marks = 278], [CustomerID = 6, Name = "Meenakshi", Marks = 289], [CustomerID = 7, Name = "Esha", Marks = 875], [CustomerID = 8, Name = "Anjali", Marks = 380] } ), #"Return Output" = Table.AlternateRows(MyTable, 3, 1, 2) in #"Return Output"
The output of the above code is shown below: