Table calculation functions are an Experimental feature.These functions may change or be updated without notice as we iterate. See feature maturity levels for details.
Pivot functions are only available when your query includes a pivoted dimension.
pivot_column
Returns the 0-based index of the current pivot column.Compiled SQL
Compiled SQL
pivot_offset
Returns the value of an expression from a pivot column at a relative offset from the current column.| Parameter | Type | Description |
|---|---|---|
expression | column reference or SQL expression | The expression to evaluate |
columnOffset | integer | Number of columns to offset. Negative = previous columns, positive = next columns, 0 = current column |
NULL if the target column is not adjacent (e.g., if intermediate columns were filtered out).
Example
Compare the current pivot column’s revenue against the previous pivot column:
Compiled SQL
Compiled SQL
For negative offsets (previous columns):For positive offsets (next columns),
LEAD is used instead of LAG.For an offset of 0, the expression is returned directly with no window function.Each call includes an adjacency guard — a CASE WHEN check that verifies the target column is actually adjacent. This prevents incorrect values when pivot columns have been filtered out and are non-contiguous.pivot_index
Returns the value of an expression from a specific pivot column by its 0-based index.| Parameter | Type | Description |
|---|---|---|
expression | column reference or SQL expression | The expression to evaluate |
pivotIndex | integer (≥ 0) | The 0-based pivot column index |
Compiled SQL
Compiled SQL
pivot_where
Finds the first pivot column where a condition is true and returns a value from that column.| Parameter | Type | Description |
|---|---|---|
selectExpression | SQL boolean expression | Condition to evaluate for each pivot column |
valueExpression | column reference or SQL expression | The expression to return from the matching column |
Compiled SQL
Compiled SQL
pivot_row
Returns an array of all values across the pivot columns for the current row.| Parameter | Type | Description |
|---|---|---|
expression | column reference or SQL expression | The expression to evaluate for each pivot column |
Compiled SQL
Compiled SQL
pivot_offset_list
Returns an array of values from consecutive pivot columns starting at a relative offset from the current column.| Parameter | Type | Description |
|---|---|---|
expression | column reference or SQL expression | The expression to evaluate |
columnOffset | integer | Starting column offset. Negative = previous columns, positive = next columns, 0 = current column |
numValues | integer | Number of consecutive pivot columns to include |
NULL when the offset points to a non-adjacent pivot column (e.g., if columns were filtered out).
Example
Get the current and two previous pivot column values:
Compiled SQL
Compiled SQL
CASE WHEN check that verifies the target column is actually adjacent. This prevents incorrect values when pivot columns have been filtered out and are non-contiguous.