OpenBI Docs Buy

HASONEVALUE

Whether the filter context leaves exactly one value in a column.

Group: Information. Compatible with DAX.

Syntax

HASONEVALUE ( <columnName> )
ParameterTypeDescription
columnNameColumnThe column whose values are counted in the current filter context.

Returns

Boolean. TRUE when exactly one value of the column is left, FALSE when none or several are.

Remarks

  • The one value may come from a filter on the column itself or from filters on other columns that reach it (cross-filtering): a category with a single product leaves one product.
  • Its usual use is as a guard: IF ( HASONEVALUE ( Products[Product] ), VALUES ( Products[Product] ) ) shows the product's name on a product's row and nothing on the total. SELECTEDVALUE does the same in one call.
  • A row context is not a filter: in ADDCOLUMNS ( VALUES ( Products[Product] ), ... ) it is FALSE until CALCULATE turns the row into a filter.
  • When the filters leave no value at all, it is FALSE.
  • To know whether a visual groups by the column, rather than whether one value is left, use ISINSCOPE.

Examples

A name on each row, a text on the total

EVALUATE
SUMMARIZECOLUMNS (
    ROLLUPADDISSUBTOTAL ( Products[Product], "Total" ),
    "Liters", [Liters sold],
    "Shown as", IF ( HASONEVALUE ( Products[Product] ), VALUES ( Products[Product] ), "All products" )
)
ORDER BY [Total], Products[Product]
Products[Product]TotalLitersShown as
CiderFALSE301074Cider
IPAFALSE331884IPA
LettølFALSE169179Lettøl
PilsFALSE1004326Pils
(blank)TRUE1806463All products

One value left by another column's filter

Beer has three products, Cider one; no product is called Stout.

EVALUATE
ROW (
    "Category Cider", CALCULATE ( HASONEVALUE ( Products[Product] ), Products[Category] = "Cider" ),
    "Category Beer", CALCULATE ( HASONEVALUE ( Products[Product] ), Products[Category] = "Beer" ),
    "Stout", CALCULATE ( HASONEVALUE ( Products[Product] ), Products[Product] = "Stout" )
)
Category CiderCategory BeerStout
TRUEFALSEFALSE

SELECTEDVALUE, HASONEFILTER, ISINSCOPE, VALUES, ISFILTERED.

Last updated · OpenBI Studio 0.3.74