Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!
Hello everyone,
I have a problem with conditional formatting.
I would like to apply custom conditional formatting to a stacked column / bar chart that has different categories on the x-axis. Example:
Please not: the range changes between the two categories.
It is possible to do that in Power Query or in DAX?
Solved! Go to Solution.
Since you can use a measure for conditional formatting you can create whatever arbitrary rules you'd like.
For example, you could write a measure similar to this
Formatting =
VAR _Cat = SELECTEDVALUE ( Table1[Category] )
VAR _Value = [AvgMeasure]
RETURN
SWITCH (
TRUE (),
_Cat = "Category 1" && _Value = 100, 1, // Green
_Cat = "Category 1" && _Value >= 50 && _Value < 100, 2, // Yellow
_Cat = "Category 1", 3, // Red
_Cat = "Category 2" && _Value = 100, 1, // Green
_Cat = "Category 2" && _Value >= 80 && _Value < 100, 2, // Yellow
_Cat = "Category 2", 3, // Red
4
)
and then set up your formatting rules like this:
Since you can use a measure for conditional formatting you can create whatever arbitrary rules you'd like.
For example, you could write a measure similar to this
Formatting =
VAR _Cat = SELECTEDVALUE ( Table1[Category] )
VAR _Value = [AvgMeasure]
RETURN
SWITCH (
TRUE (),
_Cat = "Category 1" && _Value = 100, 1, // Green
_Cat = "Category 1" && _Value >= 50 && _Value < 100, 2, // Yellow
_Cat = "Category 1", 3, // Red
_Cat = "Category 2" && _Value = 100, 1, // Green
_Cat = "Category 2" && _Value >= 80 && _Value < 100, 2, // Yellow
_Cat = "Category 2", 3, // Red
4
)
and then set up your formatting rules like this:
Vote for your favorite vizzies from the Power BI World Championship submissions!
If you love stickers, then you will definitely want to check out our Community Sticker Challenge!
Check out the January 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 16 | |
| 12 | |
| 9 | |
| 7 | |
| 6 |