Sample Data
This table lists products and their category codes.
| Cell | Value |
|---|---|
| A1 | Product |
| A2 | Apple |
| A3 | Banana |
| A4 | Cherry |
| B1 | Category Code |
| B2 | 1 |
| B3 | 2 |
| B4 | 3 |
This table lists products and their category codes.
| Cell | Value |
|---|---|
| A1 | Product |
| A2 | Apple |
| A3 | Banana |
| A4 | Cherry |
| B1 | Category Code |
| B2 | 1 |
| B3 | 2 |
| B4 | 3 |
SWITCH(B2, 1, "Fruit", 2, "Snack", 3, "Dessert", "Unknown")A B 1 Product Category Code 2 Apple -> 1 3 Banana 2 4 Cherry 3
A B C 1 Product Category Code Category Name 2 Apple 1 Fruit 3 Banana 2 4 Cherry 3
SWITCH function do in Power BI?SWITCH function in DAX?Category Result = SWITCH( 'Sales'[Category], "A", "High", "B", "Medium", "C", "Low", "Unknown" )
'Sales'[Category] is "B"?Result = SWITCH( TRUE(), Sales[Amount] > 1000, "High", Sales[Amount] > 500, "Medium", Sales[Amount] > 100, "Low" )
SWITCH formula correctly implements this?Pass the test and this pattern moves unknown