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.
SELECTEDVALUE(
columnName
[, alternateResult]
)
- 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.
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).
An alternative expression to:
SELECTEDVALUE(columnName, alternateResult)
...is
IF(
HASONEVALUE(columnName),
VALUES(columnName),
alternateResult
)
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:
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:
...we see that the function returns the only value to which the context has reduced the Geography[Country] column (Australia, in this example).