Select to view content in your preferred language

Arcade Expression to Summarize Features

2606
6
Jump to solution
11-17-2021 06:30 AM
by Anonymous User
Not applicable

Within ArcGIS Online, I want to symbolize a feature layer by a count of the district values within a single field but I'm not sure how to do that. 

For background I have a zip code polygon layer that has a table join (one to many) with a feature layer connected to a survey123. One of the prompts in the survey collects the zip code. As the survey responses come in the polygon layer is populated with the prompts. I want to symbolize that polygon layer by the frequency of each zip code occurrence in the attribute table.

For example, if 19123 appears 5 times in the table, the zip code polygon layer would reflect the value 5 and not the zip code itself.

0 Kudos
1 Solution

Accepted Solutions
JasonGlidewell
Occasional Contributor

Yes, you'll need to populate the "Extra Field" with the count.

The easiest way to do this I can think of, would be to use a filter.  It's a pretty simply command in Arcade, and can be used in a field calculate.  However, again, limitaitons apply.  Using Arcade in a field calcualte requires editor tracking to be disabled.

Something like this...

var zip = $feature.Zip_Code
var sql1 = "Zip_Code == @zip"
var filter1 = Filter($layer,sql1)
var count1 = Count(filter1)

return count1

I am normally a "question asker" not a "question answerer" so please forgive me if my answers are unclear.  Tyring to give back to this community after receiving so much help over the years.

 

 

View solution in original post

0 Kudos
6 Replies
JasonGlidewell
Occasional Contributor

Symbology with Arcade can not use FeatureSets.  So, if the data is not in the records being symbolized, this wont work.

If you were to use a field calcuate to populate a field in the feature, you could symbolize by that field.

0 Kudos
JasonGlidewell
Occasional Contributor

Re-reading what I wrote, I think I must clarify.

If I want to symbolize a polygon using an Arcade expression, the data used must be in the specific record being symbolize.  I cannot use a featureset to count the number of values within the table.

To do this, my only option would be to field calculate the count into the record, and then symbolize by the data in the record.  Notebooks does offer the option of running FCs on hosted layer in AGOL, and can even be set to run it on a regular basis, such as every 5 minutes.

 

0 Kudos
by Anonymous User
Not applicable

Thanks, Jason! 

Can you elaborate on how that would work? Would I calculate a field in the zip code layer? I added in an extra field that I could use because I had a feeling I would need it. What would the field that I use to make the calculation look like this?

Zip Code      Extra Field

19123                   3

19123                   3

19123                   3

19162                   1

19152                   2

19152                   2

0 Kudos
JasonGlidewell
Occasional Contributor

Yes, you'll need to populate the "Extra Field" with the count.

The easiest way to do this I can think of, would be to use a filter.  It's a pretty simply command in Arcade, and can be used in a field calculate.  However, again, limitaitons apply.  Using Arcade in a field calcualte requires editor tracking to be disabled.

Something like this...

var zip = $feature.Zip_Code
var sql1 = "Zip_Code == @zip"
var filter1 = Filter($layer,sql1)
var count1 = Count(filter1)

return count1

I am normally a "question asker" not a "question answerer" so please forgive me if my answers are unclear.  Tyring to give back to this community after receiving so much help over the years.

 

 

0 Kudos
by Anonymous User
Not applicable

I'll try this out! Your answers are very clear & no need to apologize for trying to help!

 

0 Kudos
JasonGlidewell
Occasional Contributor

Something similar using the diameter field.  If you Zip code field is a double, this should work after adjusting the variables.  Otherwise, if a string, you need to replace the "=" with "LIKE".

var dia = IIF(IsEmpty($feature.Diameter), 0, $feature.Diameter)
var sql1 = "Diameter = @dia"
var filter1 = Filter($layer,sql1)
var count1 = Count(filter1)

return count1

0 Kudos