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

# Resolve formula scope as an agent

Formula scope is expressed as a condition. Prefer table-derived scope over manually constructed conditions.

## Global scope

Use:

```text theme={null}
anySegment
```

Choose global scope when the user asks for a default formula or no reliable table or segment context exists.

## Resolve from a table

When a table block is available, call `resolve_table_condition` with:

* Target property ID
* Block ID
* Scenario ID
* Explicit segment values, or null for ANY

Use the returned condition with `write_formulas` and with the exact-condition `list_formulas` check.

## Manual conditions

Construct conditions manually only when dimension IDs and values are explicit and reliable.

Examples:

```text theme={null}
Department: "Sales"
```

```text theme={null}
Department: ANY
```

```text theme={null}
Department: "Sales", Date.Month: ANY
```

Use readable dimension names, backticks, and disambiguators. When several condition items are written manually, order them by dimension property ID in ascending lexicographic order.

## Do not invent scope

Do not guess dimension IDs or segment labels. If a user names a segment but no reliable table or dimension context is available, use global scope only when that matches the request; otherwise explain the missing context.

## Specificity

A specific condition can override a broad condition. Read existing formulas before writing to avoid creating an unintended competing rule.
