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 all!
I have a clustered bar chart with this year sales and last year sales as the bars. I want to have this years bar be colored red or green depending on if sales for that category exceeds that of last year. Is this possible
Hi @TuckRhodes ,
I created some data:
Here are the steps you can follow:
1. Create measure.
Measure =
var _lastyear=
SUMX(FILTER(ALL('Table'),YEAR('Table'[Date])=YEAR(TODAY())-1),[Amount])
var _currentyear=
SUMX(FILTER(ALL('Table'),YEAR('Table'[Date])=YEAR(TODAY())),[Amount])
return
SWITCH(
TRUE(),
YEAR(MAX('Table'[Date]))=YEAR(TODAY())&&_currentyear > _lastyear,"red",
YEAR(MAX('Table'[Date]))=YEAR(TODAY())&&_currentyear <= _lastyear,"green",
"blue")
2. Format – Bars – Colors -- fx.
3. Enter the Default color interface.
4. Result:
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Hello Liu!
Thanks for taking the time to provide an answer. Unfortunately, this isn't quite the scenario I was trying to describe. My sitiuation is better depicted by the above photo. Along the Y axis I have category of sales (as the main purpose of the page is to break down sales by category) and along the X axis is sales amount. Each category has two bars depending on what year it was sold but the bars come in pairs for each category just as in the image above the letters at the bottom have two bars each. So, to try and rephrase more appropriately, would there be a way to change the color of the orange(ish) bar to red or green contingent upon whether or not it is greater than the darker colored bar in each category?
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 37 | |
| 37 | |
| 33 | |
| 32 | |
| 29 |
| User | Count |
|---|---|
| 130 | |
| 88 | |
| 82 | |
| 68 | |
| 64 |