OpenBI Docs Buy

SELECTEDVALUE

A column's value when the filter context leaves exactly one, else BLANK or an alternate result.

Group: Filter. Compatible with DAX.

Syntax

SELECTEDVALUE ( <columnName> [, <alternateResult>] )
ParameterTypeDescription
columnNameColumnThe column whose single value is wanted.
alternateResultValue
optional
What to return when there is not exactly one value; BLANK when left out.

Returns

Same type as the column. The column's only value in the filter context, or else the alternate result.

Remarks

  • It counts the values the filter context leaves, also those narrowed through other columns: with Pils and IPA picked, the only category left is Beer.
  • When the one value left is blank, the result is BLANK, not the alternate result: a blank is a value too.
  • It gives the same as IF ( HASONEVALUE ( column ), VALUES ( column ), alternateResult ), in one call.
  • A total, where several values meet, gets the alternate result. Titles and labels that name the reader's choice are its common use.

Examples

By category

EVALUATE
SUMMARIZECOLUMNS (
    Products[Category],
    "One product", SELECTEDVALUE ( Products[Product], "(several)" ),
    "Or blank", SELECTEDVALUE ( Products[Product] )
)
ORDER BY Products[Category]
Products[Category]One productOr blank
Beer(several)(blank)
CiderCiderCider

A value left by another column's filter

EVALUATE
CALCULATETABLE (
    ROW (
        "Category", SELECTEDVALUE ( Products[Category], "(several)" ),
        "Product", SELECTEDVALUE ( Products[Product], "(several)" )
    ),
    Products[Product] = "Pils" || Products[Product] = "IPA"
)
CategoryProduct
Beer(several)

The one value is blank

The municipal bond has no price: one value, blank, so the alternate result is not used.

EVALUATE
CALCULATETABLE (
    ROW ( "Price", SELECTEDVALUE ( Holdings[Price], -1 ) ),
    Holdings[Bond] = "Municipal 2031"
)
Price
(blank)

HASONEVALUE, VALUES, FILTERS, ISFILTERED, LOOKUPVALUE.

Last updated · OpenBI Studio 0.3.74