> For the complete documentation index, see [llms.txt](https://docs.redivis.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.redivis.com/reference/workflows/transforms/variable-creation-methods/navigation.md).

# 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
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
