Select to view content in your preferred language

Arcade Expression for Indicator

891
3
02-17-2023 02:25 PM
Labels (1)
janderson_ksninc
Frequent Contributor

I built a dashboard that pulls from a feature layer with a related table that holds survey submissions. I would like to do calcs using values from both the parent table and related table.

I would like to take the count of all values from a field named "Remediation_Complete" that equal "Yes" from the related table and subtract that number from the total number of sites in the parent table. I'm thinking of something like this (pseudo code):

var RemComp = Count(FeatureLayerName, FieldName =="Yes") #calls the parent layer, calls the field name and counts all values that are equal to "Yes."

var TotalSite = Count(ParentTableName, ObjectID) #Calls the ParentTable and counts the total amount of records

return TotalSite -RemComp # Takes the total number of sites and subtracts the amount that have remediation completed and displays the amount left to be addressed.

Is there a way to do this in Arcade or Python?

0 Kudos
3 Replies
jcarlson
MVP Esteemed Contributor

I mean, you could use code for this, but it's just subtracting one count from another? An indicator has built-in options for this, the reference value.

jcarlson_0-1676674654863.png

You can set the reference to a totally different layer, and apply filters to one or both. So your statistic could be the county of "Yes" features in Layer A, the reference could be the count of records in Layer B.

Then just put {difference} in your indicator.

jcarlson_1-1676674833379.png

 

- Josh Carlson
Kendall County GIS
0 Kudos
janderson_ksninc
Frequent Contributor

Thanks but that totally does not work. I set the Parent layer (total number of sites) to be the "Layer A." I set the table holding the survey results to be "Layer B." In the indicator, I set the Top text to be {value}, the middle text to be {difference}, and the bottom text to be {reference} as you showed in your screenshots. 

The Top text gives my the total number of sites.

The Middle text also just displays the total number of sites.

The Bottom text just shows how many surveys have the value of "Yes" in the "Remediation_Complete" field. 

0 Kudos
janderson_ksninc
Frequent Contributor

I got it to work by switching the middle and bottom text. Thanks!

0 Kudos