Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
Maha_0221
Frequent Visitor

Can you provide alternate dax without using SWITCH statement?

Suppose you have a table called Sales with columns for Region, Product, and Revenue.
You need to create a measure that categorizes the Revenue based on the Region using the following criteria:

If the Region is "North America" or "Europe", categorize the Revenue as "Developed Markets".
If the Region is "Asia" or "South America", categorize the Revenue as "Emerging Markets".
If the Region is anything else, categorize the Revenue as "Other Markets".
hope you can provide alternate result?

@Ashish_Mathur

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Maha_0221 

 

@Ashish_Mathur  @AntrikshSharma Thank you very much for your prompt reply. Allow me to offer a different approach here.

 

@Maha_0221 For your question, here is the method I provided:

 

Here's some dummy data

 

Sales

vnuocmsft_0-1715063095626.png

 

You can create a measure. By calling a variable and making an if judgment.

 

Measure = 
VAR _REGION = SELECTEDVALUE('Sales'[region])
RETURN
IF(
    _REGION in {"North America", "Europe"}, 
    "Developed Narkets",
    IF(
        _REGION in {"Asia", "South America"},
        "Emerging Markets",
        "Other Markets"))

 

Using variables can better help you minimize the impact on performance.

 

Here is the result.

 

vnuocmsft_1-1715063321400.png

 

Regards,

Nono Chen

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

View solution in original post

6 REPLIES 6
Anonymous
Not applicable

Hi @Maha_0221 

 

@Ashish_Mathur  @AntrikshSharma Thank you very much for your prompt reply. Allow me to offer a different approach here.

 

@Maha_0221 For your question, here is the method I provided:

 

Here's some dummy data

 

Sales

vnuocmsft_0-1715063095626.png

 

You can create a measure. By calling a variable and making an if judgment.

 

Measure = 
VAR _REGION = SELECTEDVALUE('Sales'[region])
RETURN
IF(
    _REGION in {"North America", "Europe"}, 
    "Developed Narkets",
    IF(
        _REGION in {"Asia", "South America"},
        "Emerging Markets",
        "Other Markets"))

 

Using variables can better help you minimize the impact on performance.

 

Here is the result.

 

vnuocmsft_1-1715063321400.png

 

Regards,

Nono Chen

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

Ashish_Mathur
Super User
Super User

Hi,

If you insist on a measure, then try this one

Measure = if(hasonevalue(Data[Region]),if(min(Data[Region])="North America"||min(Data[Region])="Europe","Developed Markets",if(min(Data[Region])="Asia"||min(Data[Region])="South America","Emerging Markets","Other")),blank())

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
AntrikshSharma
Super User
Super User

You can create another table that has region and category and either merge them or use a relationship, but what is the issue in creating a calculated column with SWITCH?

report performance issue

Create a calculated column not a measure

this was asked in interview so he want best answer for this question

Categorize_Revenue= switch(allselected(sales(region),{"North America","Europe"},"Developed Markets", {"Asia" or "South america"},"Emerging markets",other markets))

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.