${table.column} syntax to reference fields in your results table.
Row functions use your query’s current sort order to determine row positions. Changing the sort order of your results will change the output of these functions.
PARTITION BY. If a dimension in your rows splits the data into categories (for example a region or product column), offset, index, offset_list, lookup, and row don’t reset at each category — an offset(${orders.total_revenue}, -1) can return a value from a different category’s row. If you need an offset or lag that resets per group, either:
- Use the Formula table calculation’s window functions (for example
LAG), which accept an inlinePARTITION BYclause, or - Pivot the dimension into columns and use pivot functions like
pivot_offset, which partition by row automatically.
row
Returns the 1-based row number of the current row.Compiled SQL
Compiled SQL
ORDER BY clause uses the sort order configured in your query.offset
Returns the value of a column from a row at a relative offset from the current row.offset counts rows across your whole results table, in sort order — it doesn’t restart at each value of a dimension. This makes it safe when your results have one row per step (for example a single time dimension), but unreliable once another dimension adds more than one row per step: with three categories alongside a weekly time dimension, offset(x, -52) moves back about 17 weeks, not 52, because it also steps across the other categories’ rows.
To offset within a group, use a formula table calculation with PARTITION BY, which restarts LAG/LEAD for each value of a dimension. For a prior-year or prior-period comparison on a chart with extra dimensions, use period comparison, which compares each group against its own prior period.
Example
Get the previous row’s revenue to calculate period-over-period changes:
Compiled SQL
Compiled SQL
For negative offsets (previous rows):For positive offsets (next rows):For an offset of 0, the column value is returned directly with no window function. None of these include a
PARTITION BY, so the offset always spans the whole results table.index
Returns the value of an expression from an absolute row position (1-based).
Example
Compare every row’s revenue against the first row’s revenue:
Compiled SQL
Compiled SQL
lookup
Finds a value in one column and returns the corresponding value from another column.
If multiple rows match, the largest matching value from
resultColumn is returned.
Example
Look up the revenue for a specific status:
Compiled SQL
Compiled SQL
offset_list
Returns an array of values from consecutive rows starting at a relative offset.
Example
Get the current and two previous revenue values (a 3-period window):
Compiled SQL
Compiled SQL
list
Constructs an array from multiple values. Unlike the other row functions,list does not use any windowing.
Example
Create an array of specific column values:
Compiled SQL
Compiled SQL