Forum Discussion
Conditional Formatting with Different Thresholds per Category
Hi there,
I have a matrix (screenshot below) with example data. The matrix takes the median shipment time in days for different shipment categories in different regions.
I am looking to add conditional formatting that uses different thresholds per shipment category. For example:
Air Shipment
- Green: < 10
- Yellow: >= 10
- Red: >= 20
Boat Shipment
- Green: < 30
- Yellow: >= 30
- Red: >= 50
Ground Shipment
- Green: < 20
- Yellow: >= 20
- Red: >= 30
Any ideas or ways to implement this? Thank you in advance!
Step 1) Create a color measure
CF Color = VAR _Value = [Median Shipment Days] VAR _Type = SELECTEDVALUE('Shipment'[Type]) RETURN SWITCH( TRUE(), // Air _Type = "Air Shipment" && _Value < 10, "#00B050", -- Green _Type = "Air Shipment" && _Value < 20, "#FFC000", -- Yellow _Type = "Air Shipment" && _Value >= 20, "#C00000", -- Red // Boat _Type = "Boat Shipment" && _Value < 30, "#00B050", _Type = "Boat Shipment" && _Value < 50, "#FFC000", _Type = "Boat Shipment" && _Value >= 50, "#C00000", // Ground _Type = "Ground Shipment" && _Value < 20, "#00B050", _Type = "Ground Shipment" && _Value < 30, "#FFC000", _Type = "Ground Shipment" && _Value >= 30, "#C00000" )Step 2) Apply it in the matrix
- Select your matrix
- Go to Conditional formatting → Background color (or Font color)
- Choose Format by: Field value
- Select CF Color
4 Replies
- cengizhanarslanSuper User
Step 1) Create a color measure
CF Color = VAR _Value = [Median Shipment Days] VAR _Type = SELECTEDVALUE('Shipment'[Type]) RETURN SWITCH( TRUE(), // Air _Type = "Air Shipment" && _Value < 10, "#00B050", -- Green _Type = "Air Shipment" && _Value < 20, "#FFC000", -- Yellow _Type = "Air Shipment" && _Value >= 20, "#C00000", -- Red // Boat _Type = "Boat Shipment" && _Value < 30, "#00B050", _Type = "Boat Shipment" && _Value < 50, "#FFC000", _Type = "Boat Shipment" && _Value >= 50, "#C00000", // Ground _Type = "Ground Shipment" && _Value < 20, "#00B050", _Type = "Ground Shipment" && _Value < 30, "#FFC000", _Type = "Ground Shipment" && _Value >= 30, "#C00000" )Step 2) Apply it in the matrix
- Select your matrix
- Go to Conditional formatting → Background color (or Font color)
- Choose Format by: Field value
- Select CF Color
- MikePowerBIHelper II
Thank you for your help! This measure solved what I was looking for.
- DanieleUgoCoppSuper User
Hello,
I’m not completely sure there’s a native way to do this directly per column/category, Power BI conditional formatting is a bit limited there
what usually works is creating a separate measure that returns a color based on both the value and the category, like using SWITCH with thresholds per shipment type, then applying conditional formatting based on that measure
another approach is unpivoting the data so shipment type becomes a row instead of columns, then it’s easier to apply logic per category
not super elegant, but those are the typical workarounds
Best regards,
Daniele - v-ssriganeshCommunity Support
Hi MikePowerBI,
Thank you for posting your query in the Microsoft Fabric Community Forum, and thanks to cengizhanarslan & DanieleUgoCopp for sharing valuable insights.
Could you please confirm if your query has been resolved by the provided solutions? This would be helpful for other members who may encounter similar issues.
Thank you for being part of the Microsoft Fabric Community.