Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
I have three order types based on "order" being with external customer (order type ZS02) or internal customer (order types ZS03, ZS04). I'd like to assign the legend "low margin" (on new column) based on pre-defined threshold values (per order type), or assign legend "negative margin" if the return value is -in fact- negative. The mentioned thresholds are 12% or less than 12% for order type ZS02, 7.5% or less for order type ZS03, and 6.4% or less for order type ZS04. Below a mock table of the final -desired- output (last column would be the column with the legend). How can this be accomplished?
Order | Order Type | Margin | Text assignment ( new column) |
a | zs02 | -1% | Negative Margin |
b | zs03 | 2% | Low margin |
c | zs04 | 3% | Low margin |
d | zs03 | 9% | |
e | zs04 | 10% | |
f | zs02 | 10% | Low margin |
g | zs03 | -4% | Negative margin |
h | zs02 | 16% | |
i | zs04 | 5% | Low margin |
Solved! Go to Solution.
Perhaps:
Column =
SWITCH(TRUE(),
[Margin] < 0,"Negative margin",
[Margin] <= .12 && [Order Type] = "zs02","Low margin",
[Margin] <= .075 && [Order Type] = "zs03","Low margin",
[Margin] <= .064 && [Order Type] = "zs04","Low margin",
BLANK()
)
Hi @zuro16 ,
You need a measure as below:
Measure = IF(SELECTEDVALUE('Table'[Margin])>0,
SWITCH(SELECTEDVALUE('Table'[Order Type]),
"ZS02",IF(SELECTEDVALUE('Table'[Margin])<=0.12,"low margin",BLANK()),
"ZS03",IF(SELECTEDVALUE('Table'[Margin])<=0.075,"low margin",BLANK()),
"ZS04",IF(SELECTEDVALUE('Table'[Margin])<=0.064,"low margin",BLANK()),
BLANK()),
"negative margin")
Finally,you will see:
For the related .pbix file,pls click here.
Thanks for this, but id did not work for me...it said something about the (selected value) being limited only to two tries in the formula...it worked for me with the other suggested solution
Perhaps:
Column =
SWITCH(TRUE(),
[Margin] < 0,"Negative margin",
[Margin] <= .12 && [Order Type] = "zs02","Low margin",
[Margin] <= .075 && [Order Type] = "zs03","Low margin",
[Margin] <= .064 && [Order Type] = "zs04","Low margin",
BLANK()
)
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
63 | |
55 | |
54 | |
36 | |
34 |
User | Count |
---|---|
76 | |
73 | |
46 | |
45 | |
43 |