TGViewer
Data Analytics Data Analytics @sqlspecialist · 111K subscribers
Post #3151 2.66K
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
  • ❤ 4
More from @sqlspecialist
  1. Oct 4, 20269️⃣ How would you calculate month-over-month growth? Sample Answer: “I would first retriev…
  2. Oct 4, 2026📊 Data Analyst Interview Series — Part 3 Guys, let's continue our Data Analyst Interview…
  3. Sep 29, 2026🔟 How would you find duplicate records in SQL? Sample Answer: "I would first identify the…
  4. Sep 29, 2026📊 Data Analyst Interview Series — Part 2 Guys, let's continue our Data Analyst Interview…
  5. Sep 29, 2026𝗙𝗥𝗘𝗘 𝗥𝗲𝘀𝗼𝘂𝗿𝗰𝗲𝘀 𝗧𝗼 𝗟𝗲𝗮𝗿𝗻 𝗔𝗜 𝗶𝗻 𝟮𝟬𝟮𝟲🚀 ​ Explore 6 free resource…
  6. Sep 29, 2026"After identifying duplicates, I investigate whether they are genuine duplicate records or…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →