Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more.
Get startedGrow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.
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?
Solved! Go to Solution.
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”
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.
Regards,
Nono Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
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”
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.
Regards,
Nono Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
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.
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))
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Ask questions in Eventhouse and KQL, Eventstream, and Reflex.
User | Count |
---|---|
71 | |
37 | |
21 | |
18 | |
15 |
User | Count |
---|---|
126 | |
32 | |
27 | |
24 | |
23 |