How do I use an existing arcade expression to calculate a symbology field?

1059
4
Jump to solution
03-15-2022 08:57 AM
JaredLowther
New Contributor II

Using ArcGIS Pro 2.8, I am attempting to use the Virginia Census 2020 Redistricting Blocks Data located in the living atlas to use its Race and Ethnicity Block data for an analysis. The percentages given in the fields in the attribute table for this are said to be inaccurate, and within the pop up configuration are Arcade expressions calculating the aggregated percentages (which are more accurate) for each block. I am trying to find a way to use the calculated percentages within the Arcade expressions shown in the pop ups to make a Graduated Colors symbolization for each race and ethnic group, however simply copying and pasting each expression into the symbology pane's expression builder gives the error "Invalid expression. Error on line 2. Object not found $layer". I am not familiar with Arcade language but since this is already calculated in Arcade I am looking for a solution to symbolize this data and hopefully label it as well. Attached is the error with its Arcade expression and an example of a pop up showing the data I need symbolized.

0 Kudos
2 Solutions

Accepted Solutions
jcarlson
MVP Esteemed Contributor

$layer doesn't always seem to work in Pro. Try using a FeatureSetBy function, like FeatureSetByName or FeatureSetByPortalItem, to bring in your other layers and features.

- Josh Carlson
Kendall County GIS

View solution in original post

JaredLowther
New Contributor II

Thank you for your help. Turns out replacing "$layer" with "$featureset" to calculate new fields in the attribute table did the trick. All of the data within the pop ups are now able to be symbolized.

View solution in original post

4 Replies
jcarlson
MVP Esteemed Contributor

The short answer, unfortunately, is "you don't".

Arcade has a number of different profiles, each with varying capabilities. The Visualization Profile in particular is one of the most limited. Arcade expressions here execute on a per-feature basis, and have no access to other features, even in the same layer, let alone other layers.

In order to symbolize by this kind of calculated value, you'd need to use your expression to "bake in" the values to their own attribute in the layer.

- Josh Carlson
Kendall County GIS
JaredLowther
New Contributor II

I see what you mean. However the same expression will also not work when I use it to calculate a new field, and gives me the same error message. Creating a new field to show this percentage and then symbolizing the new field would also fix the issue, however I run into the same problems with the Arcade expression. Do you know how I would need to fix the expression to calculate these values into a new field attribute?

0 Kudos
jcarlson
MVP Esteemed Contributor

$layer doesn't always seem to work in Pro. Try using a FeatureSetBy function, like FeatureSetByName or FeatureSetByPortalItem, to bring in your other layers and features.

- Josh Carlson
Kendall County GIS
JaredLowther
New Contributor II

Thank you for your help. Turns out replacing "$layer" with "$featureset" to calculate new fields in the attribute table did the trick. All of the data within the pop ups are now able to be symbolized.