DAX SELECTEDVALUE function
Returns the value of a column when exactly one value is filtered, otherwise an alternate result.
SELECTEDVALUE is how a measure knows what the user picked: one country in a slicer, the row's country in a table. It is the base of dynamic titles.
Syntax
SELECTEDVALUE(<column>[, <alternateResult>])| Argument | Required | Description |
|---|---|---|
| column | Required | The column to read. |
| alternateResult | Optional | What to return when zero or several values are in view. Blank if left out. |
Returns: A single value, or the alternate result.
Examples
Calculated on the free practice data (table financials), with [Total Sales] = SUM(financials[Sales]) and [Total Profit] = SUM(financials[Profit]).
1. The country in view
Selected Country = SELECTEDVALUE(financials[Country], "All countries")| Country | Selected Country |
|---|---|
| Canada | Canada |
| France | France |
| Germany | Germany |
| Mexico | Mexico |
| United States of America | United States of America |
| Total | All countries |
Each row has one country; the total row has five, so it shows the alternate text.
Good to know
- Use it for titles: "Sales for " & SELECTEDVALUE(financials[Country], "all countries").
Related functions
Official reference: SELECTEDVALUE function on Microsoft Learn