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.

Related Blog Posts

Loading

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

Loading

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

Loading