OpenBI Docs Buy

DISTINCT

A column's distinct values, or a table's distinct rows, without the blank row a relationship may add.

Group: Filter. Compatible with DAX.

Syntax

DISTINCT ( <column> )
DISTINCT ( <table> )
ParameterTypeDescription
columnColumnA column whose different values in the filter context are wanted.
tableTableA table expression whose repeated rows are dropped.

Returns

Table. The column's different values, or the table's different rows.

Remarks

  • For a column, it is VALUES without the blank row a relationship adds for keys the other table lacks. A blank stored in the column itself is one of its values and stays.
  • It takes any table expression: DISTINCT ( SELECTCOLUMNS ( ... ) ). Two rows are the same only when every one of their values is.
  • For a column, only the values the filter context leaves come back.

Examples

Counting the different rows

Pils from Oslo appears twice and counts once.

EVALUATE
VAR Lines =
    DATATABLE (
        "Product", STRING, "Plant", STRING,
        { { "Pils", "Oslo" }, { "Pils", "Oslo" }, { "IPA", "Bergen" }, { "Pils", "Bergen" } }
    )
RETURN
    ROW ( "Lines", COUNTROWS ( Lines ), "Different lines", COUNTROWS ( DISTINCT ( Lines ) ) )
LinesDifferent lines
43

The different rows themselves

EVALUATE
VAR Lines =
    DATATABLE (
        "Product", STRING, "Plant", STRING,
        { { "Pils", "Oslo" }, { "Pils", "Oslo" }, { "IPA", "Bergen" }, { "Pils", "Bergen" } }
    )
RETURN
    DISTINCT ( Lines )
ProductPlant
PilsOslo
IPABergen
PilsBergen

A column's values under a filter

Only IPA and Cider cost more than 50 a liter: one beer, one cider.

EVALUATE
CALCULATETABLE ( DISTINCT ( Products[Category] ), Products[Price per liter] > 50 )
ORDER BY Products[Category]
Products[Category]
Beer
Cider

VALUES, ALLNOBLANKROW, SUMMARIZE, COUNTROWS, DISTINCTCOUNT.

Last updated · OpenBI Studio 0.3.74