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.
0
0
SELECTEDVALUE and HASONEVALUE in Power BI - Dashboard Guide
Dashboard Mode - SELECTEDVALUE and HASONEVALUE
Business Question
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.
Dashboard Layout
+----------------------+----------------------+ | Selected Category KPI | Total Sales KPI | +----------------------+----------------------+ | Sales Details Table | | | +----------------------------------------------+
Interactivity
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.