Select to view content in your preferred language

Survey123 Custom Text color based on calculation

2181
7
01-25-2022 11:06 AM
Michael_VanHatten
Regular Contributor

I am trying to change the color of a calculated number based on the value that is calculated. I have a series of questions that take in values and give a unique calculation value. I would like that new value to change color based on the numeric value. (Text turns red if number is below 3.0). I cant seem to get a new if statement to work in the "calculation column" of my survey.

Any help would be awesome!

Tags (3)
0 Kudos
7 Replies
DougBrowning
MVP Esteemed Contributor

I do this but use emojis.  This how to post may help you get it.

https://community.esri.com/t5/arcgis-survey123-documents/how-to-simulate-instant-data-checking-using...

You basically do the calc in a field then use that field in the label column.

You did not post a form or the if statement so pretty hard to trouble shoot it.

Hope that helps

0 Kudos
Michael_VanHatten
Regular Contributor

Thanks Doug,

 

Here is my calculation code I know the numeric calculation works I just need the text color to change if the value is less than 3.0

 

(${building_substructure_weighted} * 5 * 0.01), if((${building_average_condition} < "3.0"),"&#9989")

0 Kudos
DougBrowning
MVP Esteemed Contributor

Not sure what you posted that is not a valid statement.  Unless this is two lines?  Your if is unbalanced.  Plus you are using a > on a string which is not going to work.

I think you are saying you want the number 3 to change color.  You can but I would not because the the html will be in the value.  Unless you have a second value to store.

I would use the emojis really.  But you can do text also.  Few diff ways to do it here.

DougBrowning_2-1643141129371.png

DougBrowning_3-1643141150913.png

Hope that helps

0 Kudos
Michael_VanHatten
Regular Contributor

Hi Doug, it looks like you got the "please check value" text to change to red. If there no way I can have two calculations for one row? I would like to calculate my value and if it is below 3.0 change it red. Is it not possible to use multiple calculation functions?

0 Kudos
DougBrowning
MVP Esteemed Contributor

Yes you can.  Just change the testint field in my sample with you calc.

0 Kudos
Michael_VanHatten
Regular Contributor

Ok I included your code but I do not get the calculated value to show up. I removed your labels and tired to call the value 

 

if((${building_substructure_weighted} * 5 * 0.01) < 3,'<font color="red">{building_average_condition}</font>',"${building_average_condition}")

 

building_average_condition is the name of the row I want to use

0 Kudos
DougBrowning
MVP Esteemed Contributor

You put the field names in quotes for some reason that makes then strings.  I think you want.

if((${building_substructure_weighted} * 5 * 0.01) < 3,'<font color="red">' + string({building_average_condition}) + '</font>',string(${building_average_condition}))

I would not use this as the value as the html will be in the data then but up to you.

0 Kudos