# Navigation

### First value

Returns the value of a variable for the first row in a given analytic window. –> [learn more](https://cloud.google.com/bigquery/docs/reference/standard-sql/functions-and-operators#first_value)

```sql
FIRST_VALUE(@variable[ @ignore_null NULLS])
```

#### Return type

dynamic (input-dependent)

#### Parameters

| Name           | Type                                                                                                                       | Allowed values                                                                           | Required | Placeholder (in UI)        |
| -------------- | -------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | -------- | -------------------------- |
| `@variable`    | [variable](https://docs.redivis.com/reference/projects/transform-nodes/variable-creation-methods/common-elements#variable) | any [Redivis type](https://docs.redivis.com/reference/datasets/variables#variable-types) | true     | -                          |
| `@ignore_null` | [enum](https://docs.redivis.com/reference/projects/transform-nodes/variable-creation-methods/common-elements#enum)         | any of: `IGNORE`, `RESPECT`                                                              | false    | *(Ignore nulls (default))* |

### Lag

Returns the value of a variable on a preceding row within the analytic window –> [learn more](https://cloud.google.com/bigquery/docs/reference/standard-sql/functions-and-operators#lag)

```sql
LAG(@variable, @literal[, @default_value])
```

#### Return type

dynamic (input-dependent)

#### Parameters

| Name             | Type                                                                                                                       | Allowed values                                                                           | Required | Placeholder (in UI) |
| ---------------- | -------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | -------- | ------------------- |
| `@variable`      | [variable](https://docs.redivis.com/reference/projects/transform-nodes/variable-creation-methods/common-elements#variable) | any [Redivis type](https://docs.redivis.com/reference/datasets/variables#variable-types) | true     | -                   |
| `@literal`       | [literal](https://docs.redivis.com/reference/projects/transform-nodes/variable-creation-methods/common-elements#literal)   | any [integer](https://docs.redivis.com/reference/datasets/variables#integer)             | false    | *(1)*               |
| `@default_value` | [literal](https://docs.redivis.com/reference/projects/transform-nodes/variable-creation-methods/common-elements#literal)   | any [Redivis type](https://docs.redivis.com/reference/datasets/variables#variable-types) | false    | *(NULL)*            |

### Last value

Returns the value of a variable for the last row in a given analytic window. –> [learn more](https://cloud.google.com/bigquery/docs/reference/standard-sql/functions-and-operators#last_value)

```sql
LAST_VALUE(@variable[ @ignore_null NULLS])
```

#### Return type

dynamic (input-dependent)

#### Parameters

| Name           | Type                                                                                                                       | Allowed values                                                                           | Required | Placeholder (in UI)        |
| -------------- | -------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | -------- | -------------------------- |
| `@variable`    | [variable](https://docs.redivis.com/reference/projects/transform-nodes/variable-creation-methods/common-elements#variable) | any [Redivis type](https://docs.redivis.com/reference/datasets/variables#variable-types) | true     | -                          |
| `@ignore_null` | [enum](https://docs.redivis.com/reference/projects/transform-nodes/variable-creation-methods/common-elements#enum)         | any of: `IGNORE`, `RESPECT`                                                              | false    | *(Ignore nulls (default))* |

### Lead

Returns the value of a variable on a subsequent row within the analytic window –> [learn more](https://cloud.google.com/bigquery/docs/reference/standard-sql/functions-and-operators#lead)

```sql
LEAD(@variable, @literal[, @default_value])
```

#### Return type

dynamic (input-dependent)

#### Parameters

| Name             | Type                                                                                                                       | Allowed values                                                                           | Required | Placeholder (in UI) |
| ---------------- | -------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | -------- | ------------------- |
| `@variable`      | [variable](https://docs.redivis.com/reference/projects/transform-nodes/variable-creation-methods/common-elements#variable) | any [Redivis type](https://docs.redivis.com/reference/datasets/variables#variable-types) | true     | -                   |
| `@literal`       | [literal](https://docs.redivis.com/reference/projects/transform-nodes/variable-creation-methods/common-elements#literal)   | any [integer](https://docs.redivis.com/reference/datasets/variables#integer)             | false    | *(1)*               |
| `@default_value` | [literal](https://docs.redivis.com/reference/projects/transform-nodes/variable-creation-methods/common-elements#literal)   | any [Redivis type](https://docs.redivis.com/reference/datasets/variables#variable-types) | false    | *(NULL)*            |

### Nth value

Returns the value at the Nth row of a given window frame. –> [learn more](https://cloud.google.com/bigquery/docs/reference/standard-sql/functions-and-operators#nth_value)

```sql
NTH_VALUE(@variable, @literal[ @ignore_null NULLS])
```

#### Return type

dynamic (input-dependent)

#### Parameters

| Name           | Type                                                                                                                       | Allowed values                                                                           | Required | Placeholder (in UI)        |
| -------------- | -------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | -------- | -------------------------- |
| `@variable`    | [variable](https://docs.redivis.com/reference/projects/transform-nodes/variable-creation-methods/common-elements#variable) | any [Redivis type](https://docs.redivis.com/reference/datasets/variables#variable-types) | true     | -                          |
| `@literal`     | [literal](https://docs.redivis.com/reference/projects/transform-nodes/variable-creation-methods/common-elements#literal)   | any [integer](https://docs.redivis.com/reference/datasets/variables#integer)             | true     | -                          |
| `@ignore_null` | [enum](https://docs.redivis.com/reference/projects/transform-nodes/variable-creation-methods/common-elements#enum)         | any of: `IGNORE`, `RESPECT`                                                              | false    | *(Ignore nulls (default))* |

### Percentile (continuous)

Computes the specified percentile value for a variable within an ordered partition, with linear interpolation. –> [learn more](https://cloud.google.com/bigquery/docs/reference/standard-sql/functions-and-operators#percentile_cont)

```sql
PERCENTILE_CONT(@variable, @literal[ @ignore_null NULLS])
```

#### Return type

float

#### Parameters

| Name           | Type                                                                                                                       | Allowed values                                                                                                                                     | Required | Placeholder (in UI)        |
| -------------- | -------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | -------------------------- |
| `@variable`    | [variable](https://docs.redivis.com/reference/projects/transform-nodes/variable-creation-methods/common-elements#variable) | any [integer](https://docs.redivis.com/reference/datasets/variables#integer), [float](https://docs.redivis.com/reference/datasets/variables#float) | true     | *(variable)*               |
| `@literal`     | [literal](https://docs.redivis.com/reference/projects/transform-nodes/variable-creation-methods/common-elements#literal)   | any [float](https://docs.redivis.com/reference/datasets/variables#float)                                                                           | true     | *(Value between \[0, 1])*  |
| `@ignore_null` | [enum](https://docs.redivis.com/reference/projects/transform-nodes/variable-creation-methods/common-elements#enum)         | any of: `IGNORE`, `RESPECT`                                                                                                                        | false    | *(Ignore nulls (default))* |

### Percentile (discrete)

Computes the specified percentile value for a variable within an ordered partition. Returns the first sorted value with cumulative distribution greater than or equal to the percentile. –> [learn more](https://cloud.google.com/bigquery/docs/reference/standard-sql/functions-and-operators#percentile_disc)

```sql
PERCENTILE_DISC(@variable, @literal[ @ignore_null NULLS])
```

#### Return type

float

#### Parameters

| Name           | Type                                                                                                                       | Allowed values                                                                                                                                     | Required | Placeholder (in UI)        |
| -------------- | -------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | -------------------------- |
| `@variable`    | [variable](https://docs.redivis.com/reference/projects/transform-nodes/variable-creation-methods/common-elements#variable) | any [integer](https://docs.redivis.com/reference/datasets/variables#integer), [float](https://docs.redivis.com/reference/datasets/variables#float) | true     | *(variable)*               |
| `@literal`     | [literal](https://docs.redivis.com/reference/projects/transform-nodes/variable-creation-methods/common-elements#literal)   | any [float](https://docs.redivis.com/reference/datasets/variables#float)                                                                           | true     | *(Value between \[0, 1])*  |
| `@ignore_null` | [enum](https://docs.redivis.com/reference/projects/transform-nodes/variable-creation-methods/common-elements#enum)         | any of: `IGNORE`, `RESPECT`                                                                                                                        | false    | *(Ignore nulls (default))* |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.redivis.com/reference/workflows/transforms/variable-creation-methods/navigation.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
