Table of contents
TOC
Collapse the table of content
Expand the table of content

SELECTEDVALUE Function

Owen Duncan|Last Updated: 5/22/2018

Returns the value when the context for columnName has been filtered down to one distinct value only. Otherwise returns alternateResult.

Syntax

SELECTEDVALUE(<columnName>[, <alternateResult>])  

Parameters

TermDefinition
columnNameThe name of an existing column, using standard DAX syntax. It cannot be an expression.
alternateResult(Optional) The value returned when the context for columnName has been filtered down to zero or more than one distinct value. When not provided, the default value is BLANK().

Return Value

The value when the context for columnName has been filtered down to one distinct value only. Else, alternateResult.

Remarks

An equivalent expression for SELECTEDVALUE(<columnName>, <alternateResult>) is IF(HASONEVALUE(<columnName>), VALUES(<columnName>), <alternateResult>).

Example

The following DAX query:

DEFINE MEASURE DimProduct[Selected Color] = SELECTEDVALUE(DimProduct[Color], "No Single Selection")
EVALUATE SUMMARIZECOLUMNS(ROLLUPADDISSUBTOTAL(DimProduct[Color], "Is Total"), "Selected Color", [Selected Color])
ORDER BY [Is Total] ASC, [Color] ASC

Returns the following:

DimProduct[Color][Is Total][Selected Color]
BlackFALSEBlack
BlueFALSEBlue
GreyFALSEGrey
MultiFALSEMulti
NAFALSENA
RedFALSERed
SilverFALSESilver
Silver/BlackFALSESilver/Black
WhiteFALSEWhite
YellowFALSEYellow
TRUENo Single Selection
© 2018 Microsoft