Skip to content

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

CALCULAR

On this page (10)

Evaluates the expression with a changed filter: TUDO() ignores the group, FILTRAR() narrows it.

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

Aliases#

Canonical name: CALCULAR. Accepted aliases (case-insensitive): calculate.

Syntax#

code
CALCULAR(expr; [arg2]; [arg3]; [arg4]; [arg5]; [arg6]; [arg7]; [arg8]; [arg9])

All arguments are expressions.

Returns#

The value of the expression evaluated in the changed context.

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#

Changes the filter context and ONLY THEN evaluates the expression (lazy evaluation) — that's why the result differs from evaluating the expression first.

Differences from DAX#

  • DAX equivalent: CALCULATE
  • Compatibility: DIFFERS from DAX — different semantics, watch out
  • Note: Modifiers limited to the engine's repertoire (plain condition, FILTRAR, TUDO, TUDO_EXCETO, REMOVER_FILTROS, ENTRE_DATAS, DATAS_NO_PERIODO, TRATAR_COMO, PRIMEIROS_N). Operates on the visual's rows, with no tabular model.

Examples#

code
CALCULAR(SOMA(receita); FILTRAR(uf = "SP"))

Example with values#

Input: sum ignoring the group filter (TUDO) → 100.

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

Expected result: 100

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