Bird
Raised Fist0
Power BIbi_tool~15 mins

SWITCH function in Power BI - Real Business Scenario

Choose your learning style10 modes available
Scenario Mode
👤 Your Role: You are a sales analyst at a retail company.
📋 Request: Your manager wants a report that categorizes each product's sales performance into 'Low', 'Medium', or 'High' based on total sales amount.
📊 Data: You have a sales data table with columns: ProductID, ProductName, SalesAmount.
🎯 Deliverable: Create a new calculated column using the SWITCH function to classify sales performance and build a simple table visual showing ProductName and its Sales Performance category.
Progress0 / 4 steps
Sample Data
ProductIDProductNameSalesAmount
101Notebook1200
102Pen300
103Desk Lamp800
104Chair1500
105Backpack400
106Calculator1000
107Stapler200
108Whiteboard1800
1
Step 1: Open Power BI Desktop and load the sales data table.
No formula needed.
Expected Result
Sales data table is loaded and visible in the Fields pane.
2
Step 2: Create a new calculated column named 'Sales Performance' in the sales data table.
Sales Performance = SWITCH(TRUE(), Sales[SalesAmount] < 500, "Low", Sales[SalesAmount] >= 500 && Sales[SalesAmount] < 1500, "Medium", Sales[SalesAmount] >= 1500, "High", "Unknown")
Expected Result
A new column 'Sales Performance' is added with values 'Low', 'Medium', or 'High' based on SalesAmount.
3
Step 3: Create a table visual on the report canvas.
Add 'ProductName' and 'Sales Performance' columns to the table visual.
Expected Result
Table visual shows each product with its sales performance category.
4
Step 4: Format the table visual for readability.
Adjust column widths and apply alternating row colors.
Expected Result
Table is easy to read with clear categories.
Final Result
-----------------------------------
| ProductName | Sales Performance |
-----------------------------------
| Notebook    | Medium            |
| Pen         | Low               |
| Desk Lamp   | Medium            |
| Chair       | High              |
| Backpack    | Low               |
| Calculator  | Medium            |
| Stapler     | Low               |
| Whiteboard  | High              |
-----------------------------------
✓Products with sales below 500 are classified as Low performance.
✓Sales between 500 and 1499 are Medium performance.
✓Sales 1500 and above are High performance.
✓This classification helps quickly identify which products need attention.
Bonus Challenge

Create a measure that counts how many products fall into each sales performance category and display it in a card visual.

Show Hint
Use the COUNTROWS and FILTER functions with the 'Sales Performance' column in your measure.

Practice

(1/5)
1. What does the SWITCH function do in Power BI?
easy
A. It filters rows based on a condition.
B. It creates a new table from existing data.
C. It chooses a result based on matching values or conditions.
D. It sums values in a column.

Solution

  1. Step 1: Understand the purpose of SWITCH

    The SWITCH function evaluates an expression and returns a result based on matching values or conditions.
  2. Step 2: Compare with other functions

    Unlike filtering or summing, SWITCH simplifies multiple IF conditions into one formula.
  3. Final Answer:

    It chooses a result based on matching values or conditions. -> Option C
  4. Quick Check:

    SWITCH picks result by matching values [OK]
Hint: Remember: SWITCH picks output based on matching input [OK]
Common Mistakes:
  • Confusing SWITCH with filtering functions
  • Thinking SWITCH creates tables
  • Assuming SWITCH sums values
2. Which of the following is the correct syntax for a basic SWITCH function in DAX?
easy
A. SWITCH(<expression>, <value1>, <value2>, <result1>, <result2>, <else_result>)
B. SWITCH(<value1>, <result1>, <value2>, <result2>, <else_result>)
C. SWITCH(<expression>, <result1>, <value1>, <result2>, <value2>, <else_result>)
D. SWITCH(<expression>, <value1>, <result1>, <value2>, <result2>, <else_result>)

Solution

  1. Step 1: Recall SWITCH syntax

    The correct syntax is SWITCH(expression, value1, result1, value2, result2, else_result).
  2. Step 2: Check option correctness

    SWITCH(<expression>, <value1>, <result1>, <value2>, <result2>, <else_result>) matches the correct order: expression first, then pairs of value and result, ending with else result.
  3. Final Answer:

    SWITCH(<expression>, <value1>, <result1>, <value2>, <result2>, <else_result>) -> Option D
  4. Quick Check:

    Correct SWITCH syntax = SWITCH(<expression>, <value1>, <result1>, <value2>, <result2>, <else_result>) [OK]
Hint: Expression first, then value-result pairs, else last [OK]
Common Mistakes:
  • Omitting the expression argument
  • Swapping values and results
  • Placing else_result in the middle
3. Given the DAX measure:
Category Result = SWITCH(
  'Sales'[Category],
  "A", "High",
  "B", "Medium",
  "C", "Low",
  "Unknown"
)

What is the result when 'Sales'[Category] is "B"?
medium
A. "High"
B. "Medium"
C. "Low"
D. "Unknown"

Solution

  1. Step 1: Identify the input value

    The input value is 'Sales'[Category] = "B".
  2. Step 2: Match input with SWITCH cases

    SWITCH checks "A" -> "High", "B" -> "Medium", "C" -> "Low". Since input is "B", result is "Medium".
  3. Final Answer:

    "Medium" -> Option B
  4. Quick Check:

    Category "B" returns "Medium" [OK]
Hint: Match input value to cases in order [OK]
Common Mistakes:
  • Choosing the first result always
  • Confusing value and result pairs
  • Ignoring the else result
4. Identify the error in this DAX formula:
Result = SWITCH(
  TRUE(),
  Sales[Amount] > 1000, "High",
  Sales[Amount] > 500, "Medium",
  Sales[Amount] > 100, "Low"
)
medium
A. Missing ELSE result for unmatched conditions.
B. Incorrect use of TRUE() in SWITCH.
C. Conditions should be separated by commas, not line breaks.
D. Sales[Amount] cannot be compared with numbers.

Solution

  1. Step 1: Analyze SWITCH with TRUE()

    Using TRUE() allows SWITCH to evaluate conditions in order.
  2. Step 2: Check for ELSE result

    No ELSE (default) result is provided, so if none match, result is blank or error.
  3. Final Answer:

    Missing ELSE result for unmatched conditions. -> Option A
  4. Quick Check:

    Always add ELSE result in SWITCH with TRUE() [OK]
Hint: Add ELSE result to cover all cases [OK]
Common Mistakes:
  • Forgetting ELSE result causes blanks
  • Thinking TRUE() is invalid in SWITCH
  • Misunderstanding condition order
5. You want to create a measure that categorizes sales amount into "Very High" (above 2000), "High" (1001-2000), "Medium" (501-1000), "Low" (1-500), and "No Sales" (0 or less). Which SWITCH formula correctly implements this?
hard
A. SWITCH(TRUE(), Sales[Amount] > 2000, "Very High", Sales[Amount] > 1000, "High", Sales[Amount] > 500, "Medium", Sales[Amount] > 0, "Low", "No Sales")
B. SWITCH(Sales[Amount], >2000, "Very High", >1000, "High", >500, "Medium", >0, "Low", "No Sales")
C. SWITCH(TRUE(), Sales[Amount] >= 2000, "Very High", Sales[Amount] >= 1000, "High", Sales[Amount] >= 500, "Medium", Sales[Amount] >= 1, "Low", "No Sales")
D. SWITCH(TRUE(), Sales[Amount] > 2000, "Very High", Sales[Amount] >= 1000, "High", Sales[Amount] >= 501, "Medium", Sales[Amount] >= 1, "Low", "No Sales")

Solution

  1. Step 1: Use SWITCH with TRUE() for condition checks

    Using SWITCH(TRUE(), ...) allows checking conditions in order from highest to lowest.
  2. Step 2: Verify condition ranges and order

    SWITCH(TRUE(), Sales[Amount] > 2000, "Very High", Sales[Amount] > 1000, "High", Sales[Amount] > 500, "Medium", Sales[Amount] > 0, "Low", "No Sales") correctly uses > 2000, > 1000, > 500, > 0, then else "No Sales". This covers all ranges without overlap.
  3. Step 3: Check other options for errors

    SWITCH(Sales[Amount], >2000, "Very High", >1000, "High", >500, "Medium", >0, "Low", "No Sales") has invalid syntax (cannot use >2000 as value). Options A and D use >= which changes boundaries and may overlap or miss exact ranges.
  4. Final Answer:

    SWITCH(TRUE(), Sales[Amount] > 2000, "Very High", Sales[Amount] > 1000, "High", Sales[Amount] > 500, "Medium", Sales[Amount] > 0, "Low", "No Sales") -> Option A
  5. Quick Check:

    Use SWITCH(TRUE()) with descending conditions [OK]
Hint: Order conditions from highest to lowest with TRUE() [OK]
Common Mistakes:
  • Using invalid syntax for conditions
  • Overlapping or missing ranges
  • Not using TRUE() for condition checks
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard