SELECTEDVALUE Function (DAX)

How does the SELECTEDVALUE function (DAX) work?

The SELECTEDVALUE function (DAX) returns Returns the value when the context for columnName has been filtered down to one distinct value only. Otherwise returns alternateResult.

SELECTEDVALUE Formula Syntax

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

How do you use the SELECTEDVALUE function?

You can used SELECTEDVALUE function to simplify the syntax required in many scenarios where you need to read a single value selected in the filter context, obtaining blank or another default value in all other cases.

Related Blog Posts

Related Support Forum Posts

SELECTEDVALUE videos
Treshhold Trigger with Selectedvalue and OR Statement
VALUES vs SELECTEDVALUE (& HASONEVALUE)

Considerations when using the SELECTEDVALUE function

It is important to remember that:

  • The SELECTEDVALUE and VALUES functions read the current filter context, not the row context;
  • When you have a row context, just use a column reference (within RELATED in case it is in a lookup table);
  • If the filter context returns zero rows for the referenced column, then SELECTEDVALUE returns the second argument – do not assume that the second argument is returned only when two or more values are selected;
  • If you use a version of DAX that does not have SELECTEDVALUE, you can use the same pattern as that described in this article, replacing SELECTEDVALUE with the corresponding syntax using HASONEVALUE / VALUES.

Related Video Tutorials

Formula examples using the SELECTEDVALUE function

= SELECTEDVALUE(DimProduct[Color], “No Single Selection”)

= IF( ISFILTERED(‘Employee Details'[Employee Team Name]), SELECTEDVALUE(‘Employee Details'[Employee Team Name], “No Selection”), “No Selection”)

= SELECTEDVALUE(‘Expense Ratio'[Expense Ratio], 0.50)

Related Course Modules

Ultimate-Beginners-Guide-To-PowerBI

Center of Excellence

DOWNLOAD


Download our comprehensive DAX Formula Reference Guide as perfect companion as you learn how to use DAX formulas within Power BI.


Download DAX Formulas Reference Guide
Download DAX Formula Reference Guide
Membership