Berserk Docs
Aggregate FunctionsMake / Collect

last

Returns the value of the expression from the row with the latest timestamp.

Equivalent to arg_max(time_column, expr).

Time column resolution order:

  1. timestamp column if present
  2. First datetime column in the schema (left to right)

Use arg_max with explicit time column if automatic resolution is not desired.

Syntax

last(expr)

Parameters

Prop

Type

Returns: any

Examples

Example 1

datatable(region:string, timestamp:datetime, raid:string)[
  "England", datetime(2024-06-08), "Lindisfarne",
  "England", datetime(2024-11-01), "York",
  "Francia", datetime(2024-03-28), "Paris"
]
| summarize last(raid) by region
region (string)timestamp (datetime)raid (string)
England2024-11-01T00:00:00ZYork
Francia2024-03-28T00:00:00ZParis

On this page