Skip to content

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

CONTD

On this page (10)

Counts distinct values in the column.

FieldValue
CategoryStatistics
TypeAggregation (operates on a set of rows)
Arity1 argument (fixed)
Compiles to SQL (calculated column)Yes
VersionFormula engine v3.

Aliases#

Canonical name: CONTD. Accepted aliases (case-insensitive): distinctcount, countd.

Syntax#

code
CONTD(coluna)

The 1st argument is the name of a column (bare identifier); the others are expressions.

Returns#

Number (count of distinct values).

Null handling#

Blank is not counted as a distinct value.

Evaluation context#

Aggregation — goes through the rows of the visual's current group.

Differences from DAX#

  • DAX equivalent: DISTINCTCOUNT
  • Compatibility: DIFFERS from DAX — different semantics, watch out
  • Note: Counts distinct values, but BLANK IS NOT counted — DAX DISTINCTCOUNT counts BLANK as one extra value when it exists.

Examples#

code
CONTD(pedido)

Example with values#

Input: uf = SP, SP, RJ.

code
CONTD(uf)  →  2

Expected result: 2

Business example#

Number of distinct customers who bought in the 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