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
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.
Thanks Josh!