> For the complete documentation index, see [llms.txt](https://docs.sortment.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.sortment.com/engage/attributes/calculated-attributes/advanced-mode.md).

# Advanced Mode

**Sortment’s Advanced Mode** empowers data-savvy users to define custom attributes using either a **visual expression builder** or **SQL logic**, depending on the attribute type. This functionality allows you to create powerful, structured metrics and dimensions that go beyond natural language-based AI prompts.

> 💡 **Tip:** For most users, AI-based attribute creation is sufficient. Use Advanced Mode when you wish to define attributes manually.

## Creating a calculated attribute using advanced mode

Sortment provides an **Advanced option** to create calculated attributes

### Open the attributes section:

1. Click the **star-shaped icon** (`✶`) in the left or top navigation bar.
2. This opens the **Attribute** page, where you can view, manage, and create new attributes.

<figure><img src="https://233844858-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmbOMKRXus6KHDbeQALkO%2Fuploads%2Fgit-blob-1ddaa9825ea3f87f5fe544ccd6f5a7165970c3f6%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

### Step 1: Click “New Attribute”

Start by clicking the **“+ New Attribute”** button at the top right of the Attribute page. Choose calculated attributes.

### Step 2: Choose attribute type

Select "Advanced Mode" as the creation method

### Step 3: Define attribute settings

* Attribute type: Select [dimension](/engage/attributes/use-cases.md#dimension-based-traits) or [metric](/engage/attributes/use-cases.md#metric-based-traits).
* Data source: Choose the relevant table (Eg., `Users`, `Accounts`)

### Step 4: Attribute details:

You'll be presented with the new calculated attribute screen, enter:

1. Attribute Name : Enter descriptive name of the attribute (e.g., `Max Premium Ridefare`)
2. Description *(Optional):* Provide additional context or purpose of the attribute. (e.g., `Highest fare a user has paid in a ride`)
3. Tags *(Optional):* Add relevant tags to categorise or identify the attribute.

### Step 5: Define attribute logic

#### Metric attributes (Visual builder - No code) Use the dropdown-based builder to define logic without SQL:

1. Property : Select the property from the dropdown (e.g, `Ridefare`)
2. Function : Choose the aggregate function (e.g., `Max` ).
3. Filter *(Optional):* Add filters to restrict the data in the calculation (e.g., `Ride Type = Premium`)

#### Dimension attributes (SQL Editor) Use SQL logic to create more advanced or real-time attributes.

> Example syntax for a dimension attribute:

```
CASE
    WHEN spend > 1000 THEN 'High Value'
    WHEN spend BETWEEN 500 AND 1000 THEN 'Medium Value'
    ELSE 'Low Value'
END AS account_segment
```

### Step 6: Finishing the attribute

1. Use the preview results button to verify the output.
2. Click finish to save the attribute.
