Skip to content

Automatic translation — the Portuguese version is the reference. View in Portuguese

TRATAR_COMO

On this page (10)

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.

FieldValue
CategoryContext and filter
TypeAggregation (operates on a set of rows)
Arity2 to 6 arguments
Compiles to SQL (calculated column)No
VersionFormula engine v3.

Aliases#

Canonical name: TRATAR_COMO. Accepted aliases (case-insensitive): treatas.

Syntax#

code
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#

code
CALCULAR(SOMA(valor); TRATAR_COMO(data_entrega; data_venda))

Example with values#

Input: group SP; visual total = 100.

code
CALCULAR(SOMA(receita); TUDO())  →  100

Expected 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.


← Back to the formula index

Related links