Which product category is selected, and what is the total sales for that category? If no single category is selected, show a message to select one.
Sample Data
Order ID
Product Category
Sales Amount
1001
Electronics
200
1002
Clothing
150
1003
Electronics
300
1004
Furniture
400
1005
Clothing
100
1006
Furniture
250
Dashboard Components
KPI Card: Selected Category Formula: Selected Category = SELECTEDVALUE('Sales'[Product Category], "Select one category") Shows the product category selected or a prompt if none or multiple are selected.
KPI Card: Total Sales for Selected Category Formula: Total Sales Selected = IF(HASONEVALUE('Sales'[Product Category]), SUM('Sales'[Sales Amount]), BLANK()) Shows total sales only if exactly one category is selected.
Table: Sales Details Shows all sales rows with Order ID, Product Category, and Sales Amount.
A slicer on Product Category lets you select one category at a time.
When you select exactly one category, the Selected Category card shows that category name, and the Total Sales Selected card shows the sum of sales for that category.
If you select none or multiple categories, the Selected Category card shows "Select one category" and the Total Sales Selected card is blank.
The sales details table always shows all rows but can be filtered by the slicer if applied.
Self Check
If you add a filter to select Product Category = Electronics, what do the KPI cards show?
Selected Category: Electronics
Total Sales Selected: 500 (200 + 300)
If you select multiple categories, what happens?
Selected Category: "Select one category"
Total Sales Selected: Blank
Key Result
Dashboard shows selected product category and its total sales using SELECTEDVALUE and HASONEVALUE.
Practice
(1/5)
1. What does the SELECTEDVALUE function do in Power BI?
easy
A. Filters the data to only one selected value
B. Checks if exactly one value is selected
C. Returns all selected values as a list
D. Returns the single selected value or a default if multiple values are selected
Solution
Step 1: Understand the purpose of SELECTEDVALUE
SELECTEDVALUE returns a single value if only one is selected; otherwise, it returns a default or blank.
Step 2: Compare with other options
HASONEVALUE checks selection count, not returning the value itself; other options describe different behaviors.
Final Answer:
Returns the single selected value or a default if multiple values are selected -> Option D
Quick Check:
SELECTEDVALUE = single value or default [OK]
Hint: SELECTEDVALUE gives one value or default if many selected [OK]
Common Mistakes:
Confusing SELECTEDVALUE with HASONEVALUE
Thinking SELECTEDVALUE returns all selected values
Assuming SELECTEDVALUE filters data
2. Which of the following is the correct syntax for using HASONEVALUE in a DAX measure?
easy
A. HASONEVALUE = ColumnName
B. HASONEVALUE[ColumnName]
C. HASONEVALUE(ColumnName)
D. HASONEVALUE(ColumnName, DefaultValue)
Solution
Step 1: Recall HASONEVALUE syntax
HASONEVALUE takes a single column as argument to check if exactly one value is selected.
Step 2: Eliminate incorrect syntax
Options A, C, and D do not follow correct function call syntax or add invalid parameters.
Final Answer:
HASONEVALUE(ColumnName) -> Option C
Quick Check:
HASONEVALUE(Column) syntax correct [OK]
Hint: HASONEVALUE takes one column as argument in parentheses [OK]
But it always returns "Multiple" even when one category is selected. What is the likely problem?
medium
A. The HASONEVALUE function is used incorrectly without a filter context
B. SELECTEDVALUE cannot be used inside IF statements
C. The column name 'Category' is misspelled
D. The measure lacks a default value in SELECTEDVALUE
Solution
Step 1: Analyze HASONEVALUE usage
HASONEVALUE depends on filter context; if no filter is applied, it returns FALSE even if one value exists.
Step 2: Understand why measure returns "Multiple"
Without proper filter context, HASONEVALUE returns FALSE, so IF returns "Multiple" always.
Final Answer:
The HASONEVALUE function is used incorrectly without a filter context -> Option A
Quick Check:
HASONEVALUE needs filter context to work [OK]
Hint: HASONEVALUE needs filter context to return TRUE [OK]
Common Mistakes:
Assuming SELECTEDVALUE can't be inside IF
Ignoring filter context importance
Not checking column spelling
5. You want to create a measure that shows the selected product name if exactly one product is selected, otherwise shows "Multiple Products". Which DAX expression correctly achieves this?
hard
A. Product Selected = IF(SELECTEDVALUE('Products'[ProductName]), HASONEVALUE('Products'[ProductName]), "Multiple Products")
B. Product Selected = IF(HASONEVALUE('Products'[ProductName]), SELECTEDVALUE('Products'[ProductName]), "Multiple Products")
C. Product Selected = SELECTEDVALUE('Products'[ProductName], HASONEVALUE('Products'[ProductName]))
D. Product Selected = HASONEVALUE('Products'[ProductName]) & SELECTEDVALUE('Products'[ProductName])
Solution
Step 1: Understand the requirement
Show product name if exactly one selected; else show "Multiple Products".
Step 2: Evaluate each option
Product Selected = IF(HASONEVALUE('Products'[ProductName]), SELECTEDVALUE('Products'[ProductName]), "Multiple Products") uses HASONEVALUE to check selection count and SELECTEDVALUE to get the name, with fallback text. Others misuse functions or syntax.
Final Answer:
Product Selected = IF(HASONEVALUE('Products'[ProductName]), SELECTEDVALUE('Products'[ProductName]), "Multiple Products") -> Option B
Quick Check:
HASONEVALUE + SELECTEDVALUE with IF = correct pattern [OK]
Hint: Use IF with HASONEVALUE and SELECTEDVALUE for conditional display [OK]
Common Mistakes:
Passing HASONEVALUE as default to SELECTEDVALUE
Using SELECTEDVALUE as condition in IF
Concatenating HASONEVALUE and SELECTEDVALUE incorrectly
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.