Select to view content in your preferred language

Arcade Expression for number of violations

749
6
Jump to solution
08-21-2023 07:26 AM
EmilySpeck
Occasional Contributor

Hello,

I am fairly new to working with arcade expressions. How do I set up an expressions to show when there are more than 5 critical violations it will change the symbol icon? 

0 Kudos
2 Solutions

Accepted Solutions
jcarlson
MVP Esteemed Contributor

Easy enough, then. Just have your expression check the value of that field and return a different value based on your threshold, then set the symbology accordingly. You can add additional else if blocks to give your symbols additional categories as needed.

if ($feature['critical_violations_field'] > 5) {
  return "More than 5"
} else {
  return "5 or fewer"
}

If not all categories are present in the result, you can manually add them.

jcarlson_0-1692630929858.png

- Josh Carlson
Kendall County GIS

View solution in original post

jcarlson
MVP Esteemed Contributor

Just add a condition to check for it, easy peasy!

if ($feature['critical_violations_field'] > 5) {
  return "More than 5"
} else if ($feature['critical_violations_field'] == 0 {
  return "0 Violations"
} else {
  return "5 or fewer"
}
- Josh Carlson
Kendall County GIS

View solution in original post

0 Kudos
6 Replies
jcarlson
MVP Esteemed Contributor

It really depends on the data. Where are the critical violations being recorded, on the layer itself, or related tables?

- Josh Carlson
Kendall County GIS
0 Kudos
EmilySpeck
Occasional Contributor

They are going to be in the layer itself

0 Kudos
jcarlson
MVP Esteemed Contributor

Easy enough, then. Just have your expression check the value of that field and return a different value based on your threshold, then set the symbology accordingly. You can add additional else if blocks to give your symbols additional categories as needed.

if ($feature['critical_violations_field'] > 5) {
  return "More than 5"
} else {
  return "5 or fewer"
}

If not all categories are present in the result, you can manually add them.

jcarlson_0-1692630929858.png

- Josh Carlson
Kendall County GIS
EmilySpeck
Occasional Contributor

How do you show the symbol with 0. I have some inspections with 0 violations but they are following under the symol with fewer violations

 

0 Kudos
jcarlson
MVP Esteemed Contributor

Just add a condition to check for it, easy peasy!

if ($feature['critical_violations_field'] > 5) {
  return "More than 5"
} else if ($feature['critical_violations_field'] == 0 {
  return "0 Violations"
} else {
  return "5 or fewer"
}
- Josh Carlson
Kendall County GIS
0 Kudos
SarahRijneke
Frequent Contributor

There are several ways that this can be accomplished. I found the following webinar very useful for setting up arcade expressions in ArcGIS Online: https://www.esri.com/arcgis-blog/products/field-maps/field-mobility/create-intuitive-field-workflows...

0 Kudos