This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. We're covering it all. You won't want to miss it.
Learn moreLevel up your Power BI skills this month - build one visual each week and tell better stories with data! Get started
Hello All,
I have each customer ranked by sales for the last 12 months. I also have their rank last year based on sales for the 12 months before that. I want to add conditonal formatting, if their rank went up - show green, if their rank went down - show red. I created the measure below:
Solved! Go to Solution.
Hi @calen ,
Try the following code:
Condittion =
SWITCH (TRUE(),
[Rank]>[Rank LY], 1,
[Rank]<[Rank LY], -1
, 0)
Regards
Miguel Félix
Proud to be a Super User!
Check out my blog: Power BI em Português@calenYou probably created a column called Rank Color and not a measure, right? I tried your exact scenario and strangely your exact formula works. Not sure why it is producing the incorrect values for you. Would it be possible for you to upload the PBIX?
Hi, @calen
Based on your description, I created data to reproduce your scenario.
You may create a measure as below.
Rank Color =
var _rank = SELECTEDVALUE('Table'[Rank])
var _rankly = SELECTEDVALUE('Table'[Rank LY])
return
IF(
_rank>_rankly,
1,
IF(
_rank<_rankly,
-1,
0
)
)
Then you need to conditonal format 'Rank' and 'Rank LY' as below.
Result:
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @calen ,
Try the following code:
Condittion =
SWITCH (TRUE(),
[Rank]>[Rank LY], 1,
[Rank]<[Rank LY], -1
, 0)
Regards
Miguel Félix
Proud to be a Super User!
Check out my blog: Power BI em PortuguêsCheck out the April 2026 Power BI update to learn about new features.
Sign up to receive a private message when registration opens and key events begin.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
| User | Count |
|---|---|
| 35 | |
| 32 | |
| 26 | |
| 21 | |
| 18 |
| User | Count |
|---|---|
| 68 | |
| 37 | |
| 33 | |
| 23 | |
| 23 |