Performance =
SWITCH(
TRUE(),
[Profit Margin] >= 0.30, "Excellent",
[Profit Margin] >= 0.15, "Good",
[Profit Margin] >= 0, "Needs Improvement",
"Loss"
)
It evaluates conditions and returns the corresponding result.
This is useful for:
✔ KPI categories
✔ Business rules
✔ Dynamic labels
✔ Conditional calculations
✔ Performance classification
🔹 10. Building a Dynamic Customer Message
You can combine these functions to create business-friendly messages.
Example:
Customer Message =
"Selected Customers: "
&
COUNTROWS(VALUES(Sales[CustomerID]))
If the current filter context contains 125 unique customers:
• Selected Customers: 125
This can be displayed inside a Card or used in a report title.
🔹 11. Why These Functions Matter
Real dashboards rarely show the same calculation under every situation.
Users interact with:
• Slicers
• Filters
• Drill-downs
• Cross-highlighting
• Page filters
Your DAX measures should respond appropriately.
Functions such as:
• "FILTER()"
• "VALUES()"
• "SELECTEDVALUE()"
• "HASONEVALUE()"
• "SWITCH()"
help you build that dynamic behavior.
🎯 Interview Questions
1️⃣ What does FILTER() do?
• It returns a filtered table based on a specified condition.
2️⃣ What does SELECTEDVALUE() return?
• The single value in the current context, or an alternate result when there isn't exactly one value.
3️⃣ What is HASONEVALUE() used for?
• To check whether exactly one unique value exists in the current filter context.
4️⃣ How can SELECTEDVALUE() be used in a dashboard?
• It can create dynamic titles, labels, messages, and calculations based on slicer selections.
5️⃣ Why is SWITCH() useful in DAX?
• It allows multiple conditions or selections to determine which result should be returned.
🧪 PRACTICE
Create a Region slicer.
Then create:
✔ Selected Region
✔ Customer Count
✔ Dynamic Sales Title
✔ Dynamic KPI using SWITCH()
✔ One Region / Multiple Regions indicator
Select different regions and observe how every measure responds.
💡 Key lesson:
Advanced DAX is largely about making calculations respond intelligently to the user's current context.
Once you understand:
• FILTER()
• VALUES()
• SELECTEDVALUE()
• HASONEVALUE()
• SWITCH()
you can start building genuinely interactive Power BI reports.
Double Tap ❤️ For More