# ENUM_LEVEL
URL: https://docs.valsight.ai/enum-level/
Description: Iterates through the values of the specified levels and returns each value with a number assigned in ascending or descending order according to the sequence in the dimension management.
**Category:** [Filtering & data shaping](/filtering-data-shaping/)

## Overview

The **ENUM\_LEVEL** function **iterates through the values of the specified levels and returns each value with a number assigned in ascending or descending order** according to the sequence in the dimension management.

Use this function when you need to number level values by their position in dimension management, for example to create index columns or define ordering rules independent of measure values.

## Syntax

`ENUM_LEVEL("Level1" [, "Level2", ...] [, "Order"])`

## Parameters

| Parameter | Description                                                                                              | Type       | Required | Default |
| --------- | -------------------------------------------------------------------------------------------------------- | ---------- | -------- | ------- |
| **Level** | One or more levels whose values are enumerated, specified in double quotes (e.g. `"Year"`, `"Country"`). | Level name | Yes      | --      |
| **Order** | Whether to enumerate in ascending or descending order.                                                   | Keyword    | No       | `"ASC"` |

**Order options:**

* `"ASC"`: Enumerates in ascending order according to the sequence in dimension management. This is the default.
* `"DESC"`: Enumerates in descending order (last value in dimension management gets number 1).

## Watch out

* If multiple levels are passed to the function, the **alphabetical order of the dimension name** and the hierarchy of levels within that dimension will determine which level takes precedence in the event of a tie.

## Examples

### Enumeration along a single level (ASC and DESC)

This example numbers each year value according to its position in dimension management, first ascending (default) then descending.

**Formula:** `ENUM_LEVEL("Year")`

| Year | ENUM\_LEVEL Result |
| ---- | ------------------ |
| 2025 | 1                  |
| 2026 | 2                  |
| 2027 | 3                  |
| 2028 | 4                  |

**Formula:** `ENUM_LEVEL("Year", "DESC")`

| Year | ENUM\_LEVEL Result |
| ---- | ------------------ |
| 2025 | 4                  |
| 2026 | 3                  |
| 2027 | 2                  |
| 2028 | 1                  |

### Enumeration across multiple levels

When multiple levels are specified, the alphabetical order of dimension names determines which level takes precedence in the combined enumeration.

**Dimensions:**

Time → Year

Location → Country

**Formula:** `ENUM_LEVEL("Year", "Country")`

| Year | Country | ENUM\_LEVEL Result |
| ---- | ------- | ------------------ |
| 2025 | France  | 1                  |
| 2026 | France  | 2                  |
| 2027 | France  | 3                  |
| 2028 | France  | 4                  |
| 2025 | Germany | 5                  |
| 2026 | Germany | 6                  |
| 2027 | Germany | 7                  |
| 2028 | Germany | 8                  |

In this example `"Location"` dimension is prioritised over `"Time"` which starts enumeration with rows having value `"France"` over `"Germany"`. Within the rows having same value, the `"Year"` level is used to further break the tie.

## Related

| Function                 | When to use instead                                                                                  |
| ------------------------ | ---------------------------------------------------------------------------------------------------- |
| [ENUM](/enum/)           | When you want to enumerate rows by measure value rather than by level order in dimension management. |
| [FINDFIRST](/findfirst/) | When you want to select one value per group rather than assign ranking numbers.                      |
