2

What course of action would you recommend if I did want to store the results of an Arcade attribute expressions to a database?

For example, right now I have a layer which includes Leveraging Partner Direct Dollars and Leveraging Partner In-Kind Dollars.

enter image description here

I’m using an attribute expression to display the sum of these attributes as Total Leveraging Partner Investment.

enter image description here

Is it possible to somehow store the Total Leveraging Partner Investment in the database?

If this is not possible to do with Arcade, is there a better way to achieve the desired outcome of storing a sum of two attributes in another attribute in ArcGIS Online?

3

Attribute Expressions are just Arcade expressions that run with the JavaScript of the page, and have nothing to do with the actual data. For instance, when a popup loads with an Attribute Expression, the Arcade simply tells the popup to add another item which is the value from an operation against the data fields. The value (in your case, sum of two fields) is being done each time the popup loads, and therefore not storing it anywhere. So - no, the value cannot be stored via Arcade Expression to the database.

ArcGIS Online does not have anything that provides a mechanism to do this. Although there have been requests to add such functionality, it really is outside of the business plan for Esri to include such functionality, as it would be an option to not use some of there software which provides such functions.

If you want to calculate the sum of two fields of data, it will take another processor to read the data, calculate, and update a sum total field. There are tools to do that, and depending on your needs some solutions may be better than others. If you need this information live and dynamically, meaning as values change in the table, you need this sum field to update, then you will need something like GeoEvent Server to monitor updates to the feature service. The GeoEvent Server server role does require special licensing and is another product that would run in the ArcGIS Enterprise environment. If you have access to the database where the data is serviced from, then you could look into a database trigger. Database triggers can be setup in the database to perform queries when other queries take place, i.e. perform a calculation and update a field when data has changed. Database triggers are only a possibility though if you have access to the database management system. If you go with GeoEvent Server or Database Triggers, just a fair warning that the data being displayed in an ArcGIS Online map still takes time (could be just a few seconds) to show the updated value. If you're using something like Collector for ArcGIS, then the updated value will take even longer to show since the update interval is not fully supported across the ArcGIS Online solution sets.

If you do not need the data to be live or dynamically calculated, you could setup a python script to run periodically as a scheduled service. The script would read the data and perform a calculation against the data. The data of course will not show the correct sum value until the service refreshes it's connection to the data store. You can setup the script to run against the local data in a database, or use the ArcGIS API for Python to update through the feature service.

  • 1
    Thank you kindly for the detailed response - this is very valuable information – Jason Matney Aug 8 '17 at 14:39

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.