DAX Function Guide

SELECTEDVALUE
Empty image or helper icon

Sam McKay

CEO & Founder

How does the SELECTEDVALUE 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?

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.

Considerations when using the SELECTEDVALUE?

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
Empty image or helper icon
Empty image or helper icon
Empty image or helper icon
Formula examples using the SELECTEDVALUE

= 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 Courses
beginner
Course Cover: Beginners Guide To DAX
Total points: 508 XP 04:26 hours

Beginners Guide To DAX

intermediate
Course Cover: Mastering DAX Calculations
Total points: 1390 XP 12:17 hours

Mastering DAX Calculations

intermediate
Course Cover: DAX Formula Patterns
Total points: 728 XP 04:55 hours

DAX Formula Patterns