SELECTEDVALUE

The SELECTEDVALUE function returns the content of the indicated column when the context has reduced the number of distinct values to one. Otherwise it returns the alternative value or Blank if it has not been added as an argument.

Syntax

SELECTEDVALUE(
    columnName
    [, alternateResult]
)

Parameters
  • columnName: Name of an existing column. It cannot be an expression.
  • alternateResult: Optional argument. Value to return when the number of distinct values in the column columnName after being filtered by the context is different than one.
Returned value

The SELECTEDVALUE function returns the value contained in the column columnName (if it is unique) or the alternative or Blank value (if it is not unique).

Additional Information

An alternative expression to:

SELECTEDVALUE(columnName, alternateResult)

...is

IF(
    HASONEVALUE(columnName),
    VALUES(columnName),
    alternateResult
)

Examples

If we define the measure

Selected Country = SELECTEDVALUE(Geography[Country], "No single country selected")

...to extract the value (if it is unique) contained in the Geography[Country] column, and we take it to a card-like display (in this example it is accompanied by a slicer with the values extracted from the same Geography[ Country], but none are selected), the result is as follows:

SELECTEDVALUE function. Example of use

We see how the function returns the alternative value ("No single country selected") since the Geography[Country] column contains all possible values (all 6 countries).

But if, in the slicer, we select a country:

SELECTEDVALUE function. Example of use

...we see that the function returns the only value to which the context has reduced the Geography[Country] column (Australia, in this example).

Related functions
Category
Filter
Submitted by admin on Fri, 01/04/2019 - 19:16