0
0
Power BIbi_tool~5 mins

SELECTEDVALUE and HASONEVALUE in Power BI - Step-by-Step Guide

Choose your learning style9 modes available
Introduction
These two functions help you check if a single value is selected in a filter or slicer. They solve the problem of showing results only when one item is chosen, avoiding confusion when multiple items are selected.
When you want to show a message or calculation only if one product is selected in a slicer.
When your report should display details for a single customer, not a group.
When you want to avoid errors caused by multiple selections in a filter.
When you want to create dynamic titles that change based on one selected category.
When you want to check if a user selected exactly one region before showing sales data.
Steps
Step 1: Open the Power BI Desktop
- Report view
You see your report canvas and fields pane
Step 2: Click New measure
- Modeling tab
A formula bar appears to write a DAX measure
Step 3: Type the measure using SELECTEDVALUE
- Formula bar
Measure calculates the selected value or returns a default
💡 Use syntax: SELECTEDVALUE(ColumnName, "Default Text")
Step 4: Create another measure using HASONEVALUE
- Formula bar
Measure returns TRUE if exactly one value is selected, otherwise FALSE
💡 Use syntax: HASONEVALUE(ColumnName)
Step 5: Add a card visual to the report
- Visualizations pane
A blank card appears on the canvas
Step 6: Drag the SELECTEDVALUE measure to the card
- Fields pane to card visual
Card shows the selected value or default text
Step 7: Add a slicer with the same column
- Visualizations pane → Slicer
You can select one or multiple values to test the measures
Before vs After
Before
Slicer allows selecting multiple products; card shows default text 'Multiple or no selection'
After
Slicer has one product selected; card shows that product name
Settings Reference
New measure
📍 Modeling tab
Create custom calculations using DAX
Default: Empty
Slicer
📍 Visualizations pane
Filter report data by selecting values
Default: Multi-select enabled
Common Mistakes
Using SELECTEDVALUE without a default value
If multiple or no values are selected, the measure returns blank, which can confuse users
Always provide a default value in SELECTEDVALUE to show a clear message
Using HASONEVALUE but not handling FALSE case
The measure returns FALSE when multiple or no values are selected, but if you don't use this result, the report may show wrong info
Use HASONEVALUE inside IF statements to control what to show when selection is not exactly one
Summary
SELECTEDVALUE returns the selected item or a default if none or many are selected.
HASONEVALUE checks if exactly one item is selected and returns TRUE or FALSE.
Use these functions to make reports respond clearly to user selections.