OpenBI Docs Buy

Table.RemoveLastN

Drops rows from the bottom: a number of them, or as long as a condition holds.

Group: Table. Power Query M has it too: a query that uses it is written as in Power BI.

Syntax

Table.RemoveLastN(table as table, optional countOrCondition as any) as table
ParameterTypeDescription
tabletableThe table to drop rows from.
countOrConditionany
optional
How many rows to drop (1 when left out), or a condition: rows are dropped from the end while it holds.

Returns

table. The rows that are left, in their order.

Remarks

  • With a condition, dropping stops at the last row that fails it, going upwards.

Examples

Without the total line

Table.RemoveLastN(#table({"Product", "Sales"}, {{"Chair", 120}, {"Desk", 340}, {"Total", 460}}))
ProductSales
Chair120
Desk340

Blank rows at the bottom

let
    Raw = #table({"Product", "Sales"}, {{"Chair", 120}, {"Desk", 340}, {null, null}, {null, null}})
in
    Table.RemoveLastN(Raw, each [Product] = null)
ProductSales
Chair120
Desk340

Table.RemoveFirstN, Table.LastN, Table.Skip.

Last updated · OpenBI Studio 0.3.79