Table.RemoveLastN

Table.RemoveLastN

Returns a table with the last N rows removed.

function (table as table, optional countOrCondition as nullable any) as table

Description

Returns a table that does not contain the last countOrCondition rows of the table table. The number of rows removed depends on the optional parameter countOrCondition.

Category

Table.Row operations

Examples

Remove the last row of the table.

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

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

Remove the last rows where [CustomerID] > 2 of the table.

Table.RemoveLastN(Table.FromRecords({[CustomerID = 1, Name = "Bob", Phone = "123-4567"],[CustomerID = 2, Name = "Jim", Phone = "987-6543"],[CustomerID = 3, Name = "Paul", Phone = "543-7890"],[CustomerID = 4, Name = "Ringo", Phone = "232-1550"]}), each [CustomerID] >= 2)

Table.FromRecords({[CustomerID=1,Name="Bob",Phone="123-4567"]})