How do I create a permanent field calculation in an AGOL feature layer?

5148
15
02-21-2020 09:15 AM
AshleyThornton
New Contributor

I have create a map to use in Collector for ArcGIS for the fire department. After using it they have a request: Once they input values for Field A and Field B, they want Field C to calculate a solution using Fields A and B.

I have used the calculate field function in AGOL (ex. Field C = Field A + Field B). However, the field will not 'remember' this calculation. I want the field calculation to stay in that field so that each time I or another user opens the map and inputs the data for A and B, it will auto-populate the value for C.  Is there a way to NOT have to run a field calculation each time I open the map?

15 Replies
JacobWatson1
New Contributor III

If your data is being hosted as a Feature Layer, you should be able to add a field and perform calculation on it.

If you go to your Feature Layer -> Data -> Context Menu on the top right of the data -> Add Field -> Click on the new fields header -> Field Calculator.

You should be able to populate the new field with the data you want with this method.

Here is a picture of what it looks like when you have the Context Menu open.

I hope this helps!

- Jacob Watson

0 Kudos
glennhazelton2
New Contributor III

if you want the values to be calculated as data is entered then you need to create an expression in field. using the calc tool will only work manually. what i have done is create a field and then in the mapviewer create an expression. this can be a combination of other fields. below is what one looks like that i built to do labeling- it does concatenation and rounding.

"Ave. Salinity:  "+Round(Average($feature["Salinity_1"],$feature["Salinity_2"],$feature["Salinity_3"]),0)

SayenaFarid_Marandi
New Contributor

Hi Glenn, 

Where did you create an expression ? in Pop-up? then we cannot populate any field . Is there any way that we can have an expression to update a field "C" every time we change fields "A" and "B"?   

AnuSawant
Occasional Contributor II

Can you please explain where to add this expression? In my case feature service has got Sync and editor tracking enabled so I can't use the Arcade expression. And as mentioned by other SQL or other calculations are just once off. 

Thanks,

Anu

0 Kudos
SallyGalewski
New Contributor II

I also have this question.  Very similar situation except my calculation is done on a related table for a hydrant feature and not the hydrant feature itself. 

(Field A \ Field B) *200 = Field C.  Depending on the results of the calculation, I want the text to change to red, if the test needs to be redone.

AnuSawant
Occasional Contributor II

Any workaround for this? I also have the same question.

0 Kudos
SallyGalewski
New Contributor II

Hi Anu,

When in AGOL, I clicked on my related table and went to the “Attribute Expressions” and clicked “Add”.  I added my expression:

Return ($feature.RLUcATP / $feature.RLUATP1) * 200      Clicked “Test” and it looked like this:

This video shows how to do it.  (about the 4 minute mark)

 

https://www.bing.com/videos/search?q=using+html+formatting+in+a+pop-up+using+arcade&&view=detail&mid...

Hope it helps!

Sally

AnuSawant
Occasional Contributor II

Thanks Sally.

0 Kudos
CVHCMaster
New Contributor

Hi Sally, 
It seems that “Attribute Expressions” created this way on maps cannot be used/referenced in dashboard displays.   So I would not be able to pick "ATP Calc" or {expression/expr0}  when I make a dashboard indicator or list.
Or am I missing how to use/reference them in dashboard displays?
Any help would be appreciated!