> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://help.sigmacomputing.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://help.sigmacomputing.com/_mcp/server.

# RaggedHierarchy

This function isn't compatible with all data platform connections. To check if your connection supports it, see [Supported data platforms and feature compatibility](/docs/region-warehouse-and-feature-support#supported-data-platforms-and-feature-compatibility).

The **RaggedHierarchy** function constructs a parent-child path across two or more columns, where each column represents a level of granularity in a hierarchical structure.

If your data is ragged (does not have a value for every level of the hierarchy), nulls are hidden by default when the hierarchy is visualized in a table.

Some common example hierarchies include:

* Product: type, family, name
* Location: continent, country, region, state, city
* Time: year, quarter, month, week, day
* Organization: department, team, role

You can also create a hierarchy in the column list. See [Work with hierarchies](/docs/hierarchies).

This function returns an ordered list that forms a hierarchy for each row.

## Syntax

```
RaggedHierarchy(level1, level2, [level3...])
```

### Function arguments

|            |                                          |
| :--------- | :--------------------------------------- |
| **level1** | The top-level value in the hierarchy.    |
| **level2** | The second-level value of the hierarchy. |
| **levelN** | Further levels in the hierarchy.         |

## Notes

* You must specify at least two values to establish a parent-child relationship.
* Values are interpreted in order, with **level1** being the highest level (parent) of the hierarchy, and each subsequent value specified is a child of the level immediately preceding it.
* A hierarchy column is most useful in a pivot table, and can also be used in a grouped table.

## Example

A table describing a company’s management organizational structure has 5 columns. The columns range from *Level 1* to *Level 5*, with a higher number indicating a more senior position.

![Input table with 5 columns of employee seniority, each with different roles in the company's management structure.](https://files.buildwithfern.com/sigma.docs.buildwithfern.com/8a21725c61341afa9df4877497a233120bc77b7fd8d1d60f14affade9d1828ad/assets/docs-images/8bcb36ae5f59dbdee26522e58219f45ed24d470e3f656cc7874232152f7a3c60-inputmanagement.png)

Some of the cells in the table are null, as that territory might not have a specific role filled, even though other territories do. You can use a hierarchy to visualize the organizational structure of this company with the following formula:

```
RaggedHierarchy([Level 5], [Level 4], [Level 3], [Level 2], [Level 1])
```

This results in a table that looks something like:

![Corporate structure hierarchy visualized in a pivot table, but with no gaps where there are null values in the organizational structure. The view is filtered to hide null values.](https://files.buildwithfern.com/sigma.docs.buildwithfern.com/539eccc03aa368ad900af0635ce626ffdddf896b610249f90329285aed780e7c/assets/docs-images/0a2500b6a70213d85a808c4b57543acaf5a9aae6b0407effeafab9f90da8e9a9-unraggedexample.png)

Even though the data is ragged (does not have a value for every level of the hierarchy), Sigma filters out the null values. Instead of seeing gaps where there is no employee in that position, the data is shown in a compact, ragged view.