> ## Documentation Index
> Fetch the complete documentation index at: https://docs.solya.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Tagging rules — conditions

> Metric and column conditions, the operator sets by data type, and how conditions combine.

A rule's `conditions` is a logical group of one or more conditions:

```json theme={null}
"conditions": {
  "operator": "AND",
  "rules": [ { "type": "METRIC", … }, { "type": "COLUMN", … } ]
}
```

* `operator` — `AND` (all must match) or `OR` (any).
* `rules` — a list of **metric** or **column** conditions.

## Metric conditions

Compare an analytics metric against a threshold.

```json theme={null}
{
  "type": "METRIC",
  "metricId": "<uuid>",
  "conditionOperator": "LOWER_OR_EQUAL",
  "thresholdValue": 7,
  "periodFilter": { "type": "LAST_30_DAYS" }
}
```

| Field               | Meaning                                                                                                     |
| ------------------- | ----------------------------------------------------------------------------------------------------------- |
| `metricId`          | A metric from the catalog (e.g. days of stock, inventory turnover, gross sales, risk score, sales trend %). |
| `conditionOperator` | See operators below.                                                                                        |
| `thresholdValue`    | The comparison value.                                                                                       |
| `periodFilter`      | Optional time window (e.g. `LAST_7_DAYS`, `LAST_30_DAYS`, `THIS_MONTH`, `ALL_TIME`).                        |

**Operators:** `LOWER_THAN`, `LOWER_OR_EQUAL`, `GREATER_THAN`, `GREATER_OR_EQUAL`,
`EQUAL`, `NOT_EQUAL`, `TOP_PERCENT`, `BOTTOM_PERCENT`.

<Note>
  For `TOP_PERCENT` / `BOTTOM_PERCENT`, `thresholdValue` is a percentile cutoff in
  `(0, 100]` evaluated across the entities in scope (e.g. "top 10% by sales").
</Note>

## Column conditions

Test a gold/silver column value directly.

```json theme={null}
{
  "type": "COLUMN",
  "columnId": "dim_products.gender_full_path_1",
  "columnOperator": "STARTS_WITH",
  "value": "M",
  "secondaryValue": null
}
```

| Field            | Meaning                                           |
| ---------------- | ------------------------------------------------- |
| `columnId`       | `"<table>.<column>"` (e.g. `dim_products.name`).  |
| `columnOperator` | Depends on the column's data type — see below.    |
| `value`          | The comparison value (string / number / boolean). |
| `secondaryValue` | Upper bound for `BETWEEN`; ignored otherwise.     |

### Operators by data type

<Tabs>
  <Tab title="String">
    `EQUALS`, `NOT_EQUALS`, `CONTAINS`, `NOT_CONTAINS`, `STARTS_WITH`, `ENDS_WITH`,
    `MATCHES_REGEX`, `IS_EMPTY`, `IS_NOT_EMPTY`.
  </Tab>

  <Tab title="Date">
    `BEFORE`, `AFTER`, `BETWEEN`, `ON_DATE`, `IS_EMPTY`, `IS_NOT_EMPTY`.
  </Tab>

  <Tab title="Boolean">
    `IS_TRUE`, `IS_FALSE`.
  </Tab>

  <Tab title="Numeric">
    `LOWER_THAN`, `LOWER_OR_EQUAL`, `GREATER_THAN`, `GREATER_OR_EQUAL`, `EQUAL`,
    `NOT_EQUAL`.
  </Tab>
</Tabs>

### Value-less operators

`IS_EMPTY`, `IS_NOT_EMPTY`, `IS_TRUE`, `IS_FALSE` take **no** `value` — the builder hides
the value input for them. `BETWEEN` is the only operator that uses `secondaryValue`.

<Note>
  Metric and column conditions can be mixed in the same rule under one `operator`
  (AND/OR), e.g. *"days of stock ≤ 7 **AND** gender starts with M"*.
</Note>
