VALUES and SELECTEDVALUE
Count visible values, not mouse clicks
VALUES(Products[Category]) gives the distinct categories available in the current context as a table. DISTINCT(Products[Category]) also gives distinct column values, but VALUES can include the special unknown blank member of a regular relationship with unmatched fact keys. A physically stored blank is a different issue; DISTINCT does not remove every blank. HASONEVALUE tests whether exactly one distinct value is present, including a possible blank member. SELECTEDVALUE(column, alternate) returns the one value when there is exactly one, otherwise the alternate for both zero and multiple values. Clearing a slicer usually removes its restriction rather than creating an empty set.
Use the Chapter 24 isolated Import model described in labs/dax-filters-relationships/README.md. Sales has five synthetic lines totaling USD 200, Products has three unique product keys, Regions has North and South, and Dates has one row per day. Relationships filter from dimension to Sales; Dates[Date] to Sales[OrderDate] is active and Dates[Date] to Sales[ShipDate] inactive. The disconnected Selector table has North, South and West. No RLS, no DirectQuery, no other filters unless stated. Create each named measure individually in Desktop; calculated columns go on the specified table. Results are predictions, not observed native execution.
Example 1 — A label that survives multi-select
Region Label = SELECTEDVALUE(Regions[Region], "Multiple or none")Region Count = COUNTROWS(VALUES(Regions[Region]))With no matrix grouping and North selected, label North and count 1. With North and South selected, label Multiple or none and count 2. Clearing the region slicer also gives count 2. To deliberately test zero visible region values, add a measure in the model:
Empty Region Label =CALCULATE([Region Label], Regions[Region] = "West")With no other filters, this returns Multiple or none because West is not a row of Regions. The count expression on an empty table returns BLANK rather than numeric zero; wrap with COALESCE only if a zero count is the desired presentation. An empty context and an unrestricted selection are not the same.
Example 2 — Hierarchy level versus one visible value
Build a matrix with Products[Category] and Products[Product] on Rows, and these measures on Values. Expand to product level and show category subtotals.
Level Label =SWITCH(TRUE(), ISINSCOPE(Products[Product]), "Product", ISINSCOPE(Products[Category]), "Category", "Total")One Product = HASONEVALUE(Products[Product])At the Home category subtotal, One Product is TRUE because Desk Lamp is its only product, yet Level Label is Category. At the Desk Lamp row it is Product. With no product filters the grand total has One Product FALSE and Level Label Total. If an external product slicer selects only Desk Lamp, the total has One Product TRUE but still Level Label Total. Use ISINSCOPE to choose subtotal behavior, not HASONEVALUE. Test the deepest level first because higher levels may also be in scope.
Unknown members and support boundaries
To inspect an unmatched key, use the earlier fact-sales-orphan.csv in a separate copy of the model; compare VALUES and DISTINCT on the dimension ProductKey, not a fact key. A regular relationship can expose an additional blank member through VALUES. Fix or explicitly classify the orphan in the data pipeline; do not silently drop it. In a clean model the two column functions ordinarily agree. SELECTEDVALUE is a scalar function, so never pass it to an argument requiring a table. Several of these functions are restricted in DirectQuery calculated columns and RLS rules; the examples here are Import measures, not RLS logic.
Practice — Explain a subtotal
Select only Desk Lamp in an external product slicer. Predict Level Label and One Product at Home subtotal, Desk Lamp detail and grand total. Then clear the slicer and predict Region Label and Region Count on a card. Explain why a cleared slicer is not an empty result.
Further official reading
Microsoft Learn: filter functions dax · Microsoft Learn: selectedvalue function dax
These links provide supporting context; the local fixture and its expected results remain unchanged.