Change font color based on calculated value

364
2
Jump to solution
02-03-2023 02:32 PM
pstango
New Contributor

Hello, 

I was trying to change the font color of a calculated value once it drops below a certain threshold. Unfortunately, the formula I came up with is not working on a couple of levels. I'm sure I'm going about this wrong, but I haven't found any solutions that address what I'm trying to do. Any help would be appreciated. 

This is the formula I came up with:

if(${s_rating}<2.25,'<font color="red">${s_rating}</font>', '<font color="green">${s_rating}</font>')

It kind of works. However instead of displaying a red or green number, I get a green "'<font color="green">${s_rating}</font>'" when the calculated value stays above my lower threshold (or red "..." when it stays above). 

 

0 Kudos
1 Solution

Accepted Solutions
DougBrowning
MVP Esteemed Contributor

Font controls are for labels not in calc field I think.  So you need a hidden calc like you have above then use that field in the label.  I am trying to remember but am not sure the value can have html just the label.

I would also consider using emojis which save a lot of space.  Code is similar. See my post on how to do that here.  https://community.esri.com/t5/arcgis-survey123-documents/how-to-simulate-instant-data-checking-using...

DougBrowning_0-1675467361650.png

Hope that helps

 

View solution in original post

2 Replies
DougBrowning
MVP Esteemed Contributor

Font controls are for labels not in calc field I think.  So you need a hidden calc like you have above then use that field in the label.  I am trying to remember but am not sure the value can have html just the label.

I would also consider using emojis which save a lot of space.  Code is similar. See my post on how to do that here.  https://community.esri.com/t5/arcgis-survey123-documents/how-to-simulate-instant-data-checking-using...

DougBrowning_0-1675467361650.png

Hope that helps

 

pstango
New Contributor

Thank you! This is a great option to allow us to flag values that fall below our threshold. Worked beautifully!