Inside CALCULAR: uses the values the 2nd column has IN THE CURRENT GROUP as a filter on the 1st — links two columns with no declared relationship. Accepts up to 3 pairs.
| Field | Value |
|---|---|
| Category | Context and filter |
| Type | Aggregation (operates on a set of rows) |
| Arity | 2 to 6 arguments |
| Compiles to SQL (calculated column) | No |
| Version | Formula engine v3. |
Aliases#
Canonical name: TRATAR_COMO. Accepted aliases (case-insensitive): treatas.
Syntax#
TRATAR_COMO(coluna; arg2; [arg3]; [arg4]; [arg5]; [arg6])The 1st argument is the name of a column (bare identifier); the others are expressions.
Returns#
CALCULAR modifier (does not return a value on its own).
Null handling#
When there is no row in the changed context, it returns blank (never zero) — a blank is more honest than a made-up zero.
Evaluation context#
Modifier — only makes sense INSIDE CALCULAR (or another context function that accepts it). Outside of that, it warns you instead of returning a wrong number.
Differences from DAX#
- DAX equivalent: TREATAS
- Compatibility: DIFFERS from DAX — different semantics, watch out
- Note: Uses the values the 2nd column has IN THE CURRENT GROUP as a filter on the 1st (pairs of columns from the visual itself), not an arbitrary table of values.
Examples#
CALCULAR(SOMA(valor); TRATAR_COMO(data_entrega; data_venda))Example with values#
Input: group SP; visual total = 100.
CALCULAR(SOMA(receita); TUDO()) → 100Expected result: 100
CALCULAR illustration — in practice TRATAR_COMO transfers the filter from one column of the visual to another (e.g., using the delivery date as if it were the sale date).
Business example#
Comparative measure — share of total, ranking, change versus another period.
Common errors#
Typos in a column name, an incompatible type, or an invalid argument become a friendly message (pt-BR) — the engine never silently returns a wrong number.