Table.AlternateRows

Table.AlternateRows is a Power Query M function that keeps an initial offset and then alternates taking and skipping rows based on specified parameters. The function returns a new table with the filtered rows.

Compatible with: Power BI Service Power BI Desktop Excel Microsoft 365

Syntax

Table.AlternateRows(
   table as table,
   offset as number,
   skip as number,
   take as number,
) as table

Description

Keeps the initial offset then alternates taking and skipping the following rows.

  • table: The input table.
  • offset: The number of rows to keep before starting iterations.
  • skip: The number of rows to remove in each iteration.
  • take: The number of rows to keep in each iteration.

Examples

Return a table from the table that, starting at the first row, skips 1 value and then keeps 1 value.

Table.AlternateRows( 
    Table.FromRecords( {
        [CustomerID = 1, Name = "Bob", Phone = "123-4567"],
        [CustomerID = 2, Name = "Jim", Phone = "987-6543"],
        [CustomerID = 3, Name = "Paul", Phone = "543-7890"]
    } ),
    1,
    1,
    1
 )

 /* Output: 
Table.FromRecords( {
    [CustomerID = 1, Name = "Bob", Phone = "123-4567"],
    [CustomerID = 3, Name = "Paul", Phone = "543-7890"]
} )
 */ 

Other functions related to Table.AlternateRows are:

BI Gorilla Blog

Last update: August 28, 2023 | Contribute » | Contributors: Rick de Groot
Microsoft documentation: https://learn.microsoft.com/en-us/powerquery-m/table-alternaterows
© 2023 BI Gorilla. All rights reserved. Content derived from Microsoft documentation is property of Microsoft Corp.