DAX SELECTEDVALUE: Handle Multiple Selections and Blanks
SELECTEDVALUE returns one distinct value or alternateResult. See how one BLANK, zero rows and multiple values differ, with test queries and outputs.
By jackey.ye · Updated 2026-11-28
SELECTEDVALUE returns the single distinct value in the column's filter context; otherwise it returns alternateResult, which defaults to BLANK(). Four states matter: one distinct value, one selected BLANK, zero rows, and multiple values. Only zero rows and multiple values trigger alternateResult — a selected BLANK is a value, not a fallback.
What Does SELECTEDVALUE Return for One Value, One BLANK, Zero Rows, and Multiple Values?
The SELECTEDVALUE reference states the rule plainly: the function returns the value when the context for columnName has been filtered down to one distinct value only, and otherwise returns alternateResult. The optional second argument is defined as the value returned when the context has been filtered to zero or more than one distinct value, and when it is not provided the default is BLANK().
That definition collapses four practical situations into two outcomes, which is why the states need separating by cause rather than by output:
One distinct value. The column is filtered to a single member, so that member is returned.
One selected BLANK. The column is filtered to its blank member only. This is still one distinct value, so
BLANKis returned as the value — not as the alternate result.Zero rows. The filter context excludes every row of the column, so no distinct value survives and
alternateResultis returned.Multiple values. More than one distinct value survives, so
alternateResultis returned.
With the default alternateResult, the second, third and fourth states all render as blank in a visual. The distinction is invisible until you supply a non-BLANK alternate result, which is the only mechanism in the function's signature that separates a genuine blank selection from an empty or multi-valued context.
Why Does a Single Selected BLANK Return BLANK While Zero Rows Returns the Alternate Result?
The mechanism runs through VALUES and HASONEVALUE. Per the VALUES reference, when the argument is a column name the function returns a one-column table of the distinct values in that column, duplicates removed, and a BLANK value can be added. The HASONEVALUE reference returns TRUE when the context for the column has been filtered down to one distinct value only, and its documented equivalent is COUNTROWS(VALUES(<columnName>)) = 1.
A slicer selection of the blank member filters the column to one row containing BLANK. VALUES returns that single row, COUNTROWS is 1, HASONEVALUE is TRUE, and SELECTEDVALUE returns the row's value — BLANK. The alternate result is never consulted, because the one-distinct-value condition was satisfied.
Zero rows is a different condition. The filter context admits no rows at all, so the distinct-value table has zero rows, COUNTROWS is 0, HASONEVALUE is FALSE, and alternateResult is returned. Multiple values gives COUNTROWS greater than 1, HASONEVALUE is again FALSE, and alternateResult is returned again. The two failing states share an outcome but not a row count.
One historical caveat is worth knowing. In a November 2017 SQLBI note, Marco Russo documented that selecting numeric 0 in a column that also contained blank was treated as two selected values, because the comparison Sales[Quantity] = 0 was also true for the blank member; HASONEVALUE returned FALSE and SELECTEDVALUE returned blank. Russo described it as a bug in the then-current implementation and noted it could change. Treat this as a dated implementation note rather than current guaranteed behavior, and validate the numeric-zero-plus-blank case in your target environment before relying on either outcome. If the model is large enough that these tests feel slow, the diagnostics in DAX performance optimization for lakehouse models apply to test measures as well.
How Do HASONEVALUE, VALUES, and SELECTEDVALUE Relate?
The reference page gives the equivalence exactly: an equivalent expression for SELECTEDVALUE(<columnName>, <alternateResult>) is IF(HASONEVALUE(<columnName>), VALUES(<columnName>), <alternateResult>). Combined with the HASONEVALUE equivalence to COUNTROWS(VALUES(<columnName>)) = 1, the whole function reduces to a row-count test on the distinct-value table.
The IF/HASONEVALUE/VALUES pattern exists because of a type problem. Microsoft's best-practices page explains that when multiple values filter the column, VALUES returns a table of multiple rows, and comparing a table of multiple rows to a scalar value results in an error. The HASONEVALUE guard is a defensive technique that prevents that comparison from ever running against a multi-row table. The same page recommends SELECTEDVALUE as the replacement, describing it as achieving the same outcome more efficiently and elegantly.
State | Distinct rows from VALUES | HASONEVALUE | VALUES result shape | SELECTEDVALUE, no alternateResult | SELECTEDVALUE with alternateResult |
|---|---|---|---|---|---|
One distinct value | 1 | TRUE | One-row, one-column table | The value | The value |
One selected BLANK | 1 | TRUE | One-row table holding BLANK | BLANK (the value) | BLANK (the value) |
Zero rows | 0 | FALSE | Empty one-column table | BLANK (the default alternateResult) | The alternateResult |
Multiple values | 2 or more | FALSE | Multi-row, one-column table | BLANK (the default alternateResult) | The alternateResult |
Note: alternateResult default | Not applicable | Not applicable | Not applicable | BLANK() when the argument is omitted | Whatever value you pass |
The table's last two columns are the operational point: without an alternate result, rows three and four are indistinguishable from row two in the output.
How Does Slicer Filter Context Produce Each State?
A slicer applies a filter to the column it is bound to, and the single-select versus multi-select setting determines whether that filter can admit one distinct value or many. For slicers disconnected from the model, DAX TREATAS for disconnected slicers covers the pattern for applying the selection as a filter. SELECTEDVALUE reads the filter context at evaluation time, so the same measure can return different results per visual, per page, and per slicer interaction.
Single-select, one item chosen. The filter admits exactly one distinct value, producing the one-value state.
Multi-select, several items chosen. The filter admits more than one distinct value, producing the multiple-values state.
Blank member selected. The filter admits the blank member only, producing the one-BLANK state.
No selection on the column. Depending on how the visual and the filter pane are configured, the column may be unfiltered rather than filtered to nothing. An unfiltered column with more than one distinct value is the multiple-values state, not the zero-rows state; a filter that matches no rows is what produces zero rows.
A card visual with no slicer on the column typically sees the unfiltered column, which is usually the multiple-values state — the reason a measure can look correct in a table row and wrong in a card. The difference is strictly filter context: the table's axis member filters the column to one value for each cell, while the card has no such member and keeps the wider filter context. Row context plays no part, because a measure doesn't inherit row context from the visual anyway. The reference page also notes that the function is not supported for use in DirectQuery mode when used in calculated columns or row-level security rules, so validate measure behavior against the target model's storage mode.
How Do I Build a Persistent Fixture That Covers All Four States?
The fixture below is a calculated table, so it persists in the model and every test query can reference it without external data. It holds one deliberate duplicate and one deliberate BLANK member. Run the whole workflow in this order:
Create the calculated fixture table. In Power BI Desktop use Modeling → New table (or Tabular Editor's calculated-table editor), replace the default expression with the
DATATABLEdefinition below, and commit.Check the fixture before testing. Run
EVALUATE RegionFixturein DAX Query View. You should see six rows, andCOUNTROWS(VALUES(RegionFixture[Region]))should return 4 —North,South,Westand BLANK. (VALUESremoves duplicates only on a column argument; on a table name the duplicateNorthrows survive.)Run each state test in DAX Query View. Open DAX Query View from the ribbon, paste a test query from the next section, and run it with Run (or F5). Each
EVALUATEquery returns a one-row table, so a card-less result grid is all you need. Microsoft documents the mechanics in DAX query view.Compare against the expected output. Match
SelectedandHasOneagainst the hand-derived predictions. A mismatch means either the fixture differs from the definition or the model behaves differently from the documentation — record which.Validate the storage mode. Repeat any critical test against the model in DirectQuery mode if that is how it will ship; the function is documented as unsupported there for calculated columns and RLS rules.
Example configuration — validate in your target environment.
RegionFixture =
DATATABLE (
"Region", STRING,
"Amount", INTEGER,
{
{ "North", 100 },
{ "North", 150 },
{ "South", 200 },
{ "West", 250 },
{ BLANK(), 300 },
{ BLANK(), 350 }
}
)
The table has 6 rows and 4 distinct Region values including BLANK. The duplicate North rows and the two BLANK rows exist so that a filter on the column can be driven to one value, to BLANK only, to nothing, or to several values.
What Do the Executable Test Queries Return, and Why Are They Marked Unexecuted?
Each query below is runnable against RegionFixture. The expected outputs are hand-derived from the six fixture rows and the documented return rule; they are predictions, not observed results. Nothing here was executed, so confirm every row in your own environment before treating it as a regression baseline.
Example configuration — validate in your target environment.
-- Test 1: one distinct value
EVALUATE
CALCULATETABLE (
ROW (
"Selected", SELECTEDVALUE ( RegionFixture[Region], "<multiple or none>" ),
"HasOne", HASONEVALUE ( RegionFixture[Region] )
),
RegionFixture[Region] = "North"
)
Unexecuted, hand-derived: the filter admits one distinct value, so Selected = North, HasOne = TRUE, and the alternate result is never used. Drop the CALCULATETABLE wrapper and the same ROW sees all four distinct values, which puts it in the multiple-values state and returns Selected = <multiple or none>, HasOne = FALSE — a useful contrast to run alongside Test 5.
-- Test 2: one selected BLANK
EVALUATE
CALCULATETABLE (
ROW (
"Selected", SELECTEDVALUE ( RegionFixture[Region], "<multiple or none>" ),
"HasOne", HASONEVALUE ( RegionFixture[Region] )
),
RegionFixture[Region] = BLANK ()
)
Unexecuted, hand-derived: Selected = blank, HasOne = TRUE. The blank here is the value, not the alternate result — the alternate result would have read <multiple or none>.
-- Test 3: zero rows
EVALUATE
CALCULATETABLE (
ROW (
"Selected", SELECTEDVALUE ( RegionFixture[Region], "<multiple or none>" ),
"HasOne", HASONEVALUE ( RegionFixture[Region] )
),
RegionFixture[Region] = "East"
)
Unexecuted, hand-derived: Selected = <multiple or none>, HasOne = FALSE. No fixture row has East, so the distinct-value table is empty.
-- Test 4: multiple values, default alternateResult
EVALUATE
ROW (
"Selected", SELECTEDVALUE ( RegionFixture[Region] ),
"HasOne", HASONEVALUE ( RegionFixture[Region] )
)
Unexecuted, hand-derived: Selected = blank, HasOne = FALSE. Four distinct values are in context and the default alternate result is BLANK().
-- Test 5: multiple values, non-BLANK alternateResult
EVALUATE
ROW (
"Selected", SELECTEDVALUE ( RegionFixture[Region], "<multiple or none>" ),
"HasOne", HASONEVALUE ( RegionFixture[Region] )
)
Unexecuted, hand-derived: Selected = <multiple or none>, HasOne = FALSE. Comparing Test 4 with Test 5 is the whole argument for supplying an alternate result: only Test 5 distinguishes multiple values from a genuine blank selection.
Why Is SELECTEDVALUE Not a Concatenation Function?
SELECTEDVALUE returns a scalar: one value or the alternate result. It never joins multiple values into a string, and when the context holds several values it returns alternateResult rather than a comma-separated list. A measure written as SELECTEDVALUE(Table[Column]) on a multi-select slicer will show blank or your sentinel — not the selections joined together.
The function that does concatenate is CONCATENATEX, which concatenates the result of an expression evaluated for each row in a table. Its syntax is CONCATENATEX(<table>, <expression>[, <delimiter>[, <orderBy_expression>[, <order>]]...]), and it returns a concatenated string. The delimiter is optional, and the reference notes that concatenated values are not necessarily sorted in any particular order unless orderBy_expression is specified.
The contrast is short: SELECTEDVALUE answers "which one is selected," and CONCATENATEX answers "list them all." If a report needs to show every selected region, that is a CONCATENATEX measure over VALUES(RegionFixture[Region]), not a SELECTEDVALUE measure. CONCATENATEX carries the same DirectQuery limitation for calculated columns and row-level security rules.
How Should You Choose Between SELECTEDVALUE, HASONEVALUE, and CONCATENATEX?
Match the function to the question the report is asking. If you need the single selected value with a fallback, use SELECTEDVALUE with an explicit alternateResult. If you need to branch on whether exactly one value is selected — to suppress a comparison, for example — use HASONEVALUE. If you need a display string of all selected values, use CONCATENATEX.
The design decision that carries the most weight is the sentinel. A non-BLANK alternateResult is what lets a report distinguish "nothing selected" from "several selected" from "blank selected"; choosing its value, and documenting it, belongs to the report author rather than to the function. Where several reports share the same measure, a governed semantic layer with one agreed definition and one agreed sentinel removes the ambiguity at the source; Singdata describes its lakehouse as exposing one semantic layer and one set of permissions across its interfaces, which is the property that keeps such definitions consistent as models grow.
Frequently Asked Questions
Does SELECTEDVALUE return BLANK when the user selects the blank member of a slicer?
Yes. A single selected BLANK is a one-distinct-value state, so the function returns that BLANK as the value; it is not the alternate result. Because the output looks identical to the default alternateResult, supply a non-BLANK sentinel to tell the two cases apart.
Can SELECTEDVALUE return more than one value?
No. It returns a scalar — the single distinct value or the alternate result. Multiple values in context produce the alternate result, never a list. Use CONCATENATEX when the report needs list output.
What happens if I omit the alternateResult argument?
The default is BLANK(), per the reference page. Zero rows and multiple values then both return BLANK and become indistinguishable from a genuine blank selection unless you pass a sentinel value.
Does SELECTEDVALUE work in DirectQuery mode?
The reference page states it is not supported in DirectQuery mode when used in calculated columns or row-level security rules; measures are not named in that exclusion. Validate the behavior against your target model's storage mode before shipping.
Why does my measure return the alternate result in a card visual but the right value in a table?
A card evaluates the measure once with no axis member on the column, so it keeps the unfiltered or multi-value filter context and hits the multiple-values state. A table cell sits on an axis that filters the column to one value, so the same measure sees a one-distinct-value context. The mechanism is filter context alone, not row context. Add a slicer or a CALCULATE filter to constrain the column.
Sources Checked
Checked 2026-11-28 against Microsoft Learn: the SELECTEDVALUE reference (last updated 2024-12-13) for the return rule, alternateResult default and the DirectQuery limitation; HASONEVALUE (2024-04-25) for the COUNTROWS(VALUES(...)) = 1 equivalence; VALUES (2024-04-25) for distinct values and the added BLANK member; Use SELECTEDVALUE instead of VALUES (2023-12-13) for the IF/HASONEVALUE/VALUES guard and the recommendation; and CONCATENATEX (2024-04-25) for delimiter and order-by arguments. The historical note on numeric 0 and blank comes from Marco Russo's SQLBI post, Strange behavior of HASONEVALUE and SELECTEDVALUE, dated 13 November 2017 and describing the Power BI behavior of November 2017; it is not a statement about current builds. All fixture code and expected outputs in this article are hand-derived and unexecuted — validate them in your target environment.
End of article.