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?
It seems like we should be able to accomplish this - making a calculated column usable in a dashboard indicator or list - by writing an advanced formatting arcade expression. For the life of me though, I cannot seem to figure it out the correct code. In my head, here's the way it would work
Great in theory, but I cannot seem to make it actually work. This sort of thing is super simple in Power BI - making a calculated column. But all of the Googling and trying I've done so far say it's either difficult or impossible in ArcGIS Dashboards.
I'm happy to share my nonfunctioning code if anyone thinks they can actually make this work.
Same problem here..
This worked! Thanks @SallyGalewski ! Can't wait to implement this in some of my maps. The only thing I noticed that didn't seem to work was labeling off of this expression field. That'd be a nice addition so the field crews see the calc'd value right away.
Hi, I am also struggling for this question and haven't figured out a solution to fix it. dashboard doesn't inherit AGOL expression. it doesn't add to the feature layer itself, but only the pop-up. is there any way to fix this issue. I have a lot of calculated field in attribute table. I need the attribute table to automatically calculate and remember the calculated field when i append new row of data. Eventually, the information is captured automatically in dashboard configured list of element
I too have been struggling with this for quite a while and have found a bit of a solution! (if you have access to ArcPro).
I pull my feature layer out of the portal into ArcPro and put the Calculate Field into a Model scheduled to run periodically.
Only downside I see to this is that the machine with the Scheduled Tool has to be on in order for this to work. As I understand it, ArcPro doesn't even have to be open.
Hope this helps!
I just tested this out on some scrap data and this works brilliantly. It is in no way shape or form the ideal solution to this issue, but hey, any solution is better than no solution.
Thanks for sharing!
would it be possible to do this using Notebooks?
I believe so. It's something that I'm experimenting now. Having issue's with the arcpy.management CalculateField module though.
I have been able to get this to work in notebooks. It runs faster than in a model builder. And you have access to more Python modules.
I use an acrade script to create a popup that calcs two dates against each other. Seems like you could do the same for other fields. I got this template from a forum on here (sorry, I forgot where or I'd give them credit). Anyway, here's mine. Must be used in the new map viewer, so add this as one of your expressions, then in the popup add {expr/1} or whatever number it is:
// Access 'Inspections' table as a FeatureSet
var portal = Portal("PORTAL ADDRESS HERE")
var inspections = FeatureSetByPortalItem(portal,
"ITEM NUMBER HERE", <layer # in service here>, ['field1', 'field2',
'field3'])
// Filter related features by using a common attribute
var facilityid = $feature.parentID
var filterStatement = 'childID = @parentID'
// Related features as a variable
var relatedData = Filter(inspections, filterStatement)
// Sort related features by oldest to newest
var relatedDataSorted = Top(OrderBy(relatedData, 'field3 DESC'),1)
// Build the pop-up string by iterating through all related features
var popupString = 'Last Flushed Date: '
for (var f in relatedDataSorted){
popupString += Text(f.field3, 'MM/DD/YYYY')
}
DefaultValue(popupString, 'No measurements to show')