0

I am trying to create an immediate calculation attribute rule for a feature class in ArcGIS Pro (that I hope carries over when published as a feature service on AGOL).

I understand the basic syntax: IIF(condition, trueValue, falseValue). So if I wanted to create a rule that would take a value in my fictitious FoodName field and auto-calculate my FoodType field, I could do some thing like...

var food = $feature.FoodName
IIF(food == 'Carrot', 'Vegetable', 'Fruit')

This would, whenever the value 'Carrot' appears in the FoodName field, calculate the FoodType field to 'Vegetable.' My question: How do you pass a list of values to the condition in these statements? This has been surprisingly not straight forward to find online.

For instance, I would like the values 'Carrot', 'Celery', 'Parsnip', and 'Broccoli' to all to auto calculate to 'Vegetable.' Is it possible to pass a list to the condition, rather than writing multiple IIF statements? What is the preferred syntax?

  • Pretty sure even if you get the rule you want implemented, it won't publish to AGOL. If you were working with portal you can reference your SDE dataset with the rule. – Anna Forrest Oct 12 at 22:16
  • Sadly this is correct. I want the data to remain as a feature service on AGOL for permissions management. It's too bad....its on GeoNet as a fairly popular idea but so far there are no plans to implement it. – TravisB Oct 14 at 18:36
  • There is new webhooks functionality that was just released on AGOL not that long ago. See esri.com/arcgis-blog/products/arcgis-online/…. You could call an FME service or integromat etc to implement a pseudo attribute rule – Anna Forrest Oct 15 at 9:10
1

For your arcade expression try something like this:

var veges= ['Carrot','Celery','Broccoli']
IIF( indexof(veges, food ) > -1 , 'Vegetable', 'Fruit') 
| improve this answer | |
  • Anna do you have recommendations for how to make this happen in Python in the same way? For instance, if I had a list of veggies ( veg = ['Carrot', 'Celery', 'Broccoli'] ) and a list of fruits ( fruit = ['Apple', 'Banana', 'Mango'] ), the syntax for 'if value in veg, return 'Vegetable' elif value in fuit, return 'Fruit' – TravisB Oct 16 at 17:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.