OpenBI Docs Buy

Table.LastN

The last rows of a table: a number of them, or as many as meet a condition from the bottom up.

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

Syntax

Table.LastN(table as table, countOrCondition as any) as table
ParameterTypeDescription
tabletableThe table to read.
countOrConditionanyHow many rows to keep, or a condition: rows are kept from the bottom while it holds.

Returns

table. The rows kept, in the table's order.

Remarks

  • With a condition, the first row from the bottom that fails it ends the result.

Examples

The last two lines

Table.LastN(#table({"Product", "Price", "Units"}, {{"Chair", 50, 4}, {"Desk", 120, 1}, {"Lamp", 30, 6}}), 2)
ProductPriceUnits
Desk1201
Lamp306

From the bottom while the price is under 100

let
    Lines = #table({"Product", "Price"}, {{"Chair", 50}, {"Desk", 120}, {"Lamp", 30}, {"Rug", 80}})
in
    Table.LastN(Lines, each [Price] < 100)
ProductPrice
Lamp30
Rug80

Table.FirstN, Table.Last, Table.RemoveLastN.

Last updated · OpenBI Studio 0.3.79