Select to view content in your preferred language

Change the color of text in a Dashboard List, based on the Value (Yes/No, or Pass/Fail, etc.).

697
2
09-16-2024 03:01 PM
MarkDuvall_ccec
Emerging Contributor

I’m trying to use the “Advanced formatting” section in a Dashboard List to change the color of the text for a field based on the attribute value of that field (e.g., “Yes” = Red, “No” = Green)

I’ve seen examples that have similar solutions, but I can’t figure out how to make it work for this specific example. Also, I’m not much of a coder, so any help would be greatly appreciated.

Thanks

0 Kudos
2 Replies
jcarlson
MVP Esteemed Contributor

The simplest is to use Iif to assign the color based on the field. For something this direct, you don't even need to mess around with variables. Put this in your advanced formatting section:

 

return {
  textColor: Iif($datapoint['fail'] == 'Yes', 'red', 'green')
}

 

Feel free to swap the color names with hex codes to get the colors how you want them.

Edit: I had my red and green mixed up! Edited the code block.

- Josh Carlson
Kendall County GIS
MarkDuvall_ccec
Emerging Contributor

Thanks Josh!

0 Kudos