Skip to main content

Table.Last

Returns the last row or a specified default value.

Syntax

Table.Last(
table as table,
optional default as any
) as any

Remarks

Returns the last row of the table or an optional default value, default, if the table is empty.

Examples

Example #1

Find the last row of the table.

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

Result:

[CustomerID = 3, Name = "Paul", Phone = "543-7890"]

Example #2

Find the last row of the table <code>({})</code> or return [a = 0, b = 0] if empty.

Table.Last(Table.FromRecords({}), [a = 0, b = 0])

Result:

[a = 0, b = 0]

Category

Table.Row operations