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!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
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:
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 19 | |
| 10 | |
| 9 | |
| 8 | |
| 7 |