SELECTEDVALUE and HASONEVALUE in DAX

How SELECTEDVALUE and HASONEVALUE read what the reader selected in DAX, dynamic titles, what-if parameters and measure switches, the alternate result, ISFILTERED and ISCROSSFILTERED, CONCATENATEX for several selections, and the total row trap.

Short answer: SELECTEDVALUE ( column, alternate ) returns the column's value when the current filter context has exactly one distinct value, and the alternate result (BLANK by default) when it has none or several. HASONEVALUE ( column ) returns TRUE in the same case. Use them for dynamic titles ("Revenue for Bikes"), reading a what-if slicer, switching measures, and hiding numbers at total level. Microsoft lists SELECTEDVALUE ( col, alt ) as equivalent to IF ( HASONEVALUE ( col ), VALUES ( col ), alt ).

A report title that says "Revenue" whatever is selected makes readers check the slicers. A title that says "Revenue for Bikes, 2026" answers that before they ask.

What do they return?

ContextHASONEVALUESELECTEDVALUE
Slicer on BikesTRUEBikes
Slicer on Bikes and ClothingFALSEAll categories
No selection (all four)FALSEAll categories
Row "Bikes" in a tableTRUEBikes
Total rowFALSEAll categories
SELECTEDVALUE ( 'Product'[Category], "All categories" ) in different contexts

What are everyday uses?

-- dynamic title
Title =
"Revenue for " & SELECTEDVALUE ( 'Product'[Category], "all categories" )
    & ", " & SELECTEDVALUE ( 'Date'[Year], "all years" )

-- what-if parameter: a disconnected table of discounts 0% to 30%
Discount Selected = SELECTEDVALUE ( Discount[Discount], 0 )
Revenue after Discount = [Revenue] * ( 1 - [Discount Selected] )

-- switch measures from a slicer on a small table of names
Selected Metric =
SWITCH (
    SELECTEDVALUE ( Metric[Name], "Revenue" ),
    "Revenue", [Revenue],
    "Margin", [Margin],
    "Orders", [Orders]
)

-- hide a value at total level
Price per Unit =
IF ( HASONEVALUE ( 'Product'[Product] ), DIVIDE ( [Revenue], [Units] ) )

For the measure switch, field parameters are often the better tool today, as they also switch formats and work on axes.

What if several values are selected?

List them with CONCATENATEX:

Selected Categories =
VAR N = COUNTROWS ( VALUES ( 'Product'[Category] ) )
RETURN
    IF (
        N <= 3,
        CONCATENATEX ( VALUES ( 'Product'[Category] ), 'Product'[Category], ", ", 'Product'[Category] ),
        N & " categories"
    )

It reads "Bikes, Clothing" or "4 categories".

How do ISFILTERED and ISCROSSFILTERED differ?

FunctionTRUE when
HASONEVALUE ( col )exactly one value of col is visible, by any route
ISFILTERED ( col )col itself has a direct filter (a slicer on it, a row of the visual)
ISCROSSFILTERED ( col )col is filtered directly or through another column or table
ISINSCOPE ( col )col is the level being grouped in the visual (see ISINSCOPE)

A product filtered to one category through a Product slicer makes HASONEVALUE ( 'Product'[Category] ) TRUE but ISFILTERED ( 'Product'[Category] ) FALSE.

What goes wrong?

  • VALUES instead of SELECTEDVALUE. VALUES ( col ) returns a table; used as a scalar with several values it errors ("A table of multiple values was supplied"). Microsoft's guidance: use SELECTEDVALUE.
  • No alternate result. BLANK in a title reads "Revenue for "; give an alternate.
  • Totals disappear. IF ( HASONEVALUE ( ... ) ) blanks totals on purpose; make sure that is wanted.
  • What-if default. Without an alternate, a cleared what-if slicer returns BLANK and the formula breaks; give a default.

Where can you check this?

Where do you start?

Add a dynamic title measure to your main page and bind it to the visual title with fx. ISINSCOPE handles different logic at total and detail level.

Keep reading

More from the blog.

Every post

Next

Building this? Say hello.

A question about this post, a pattern you would build differently, or the next thing you want written out: Behnia reads every message.