Arcade Expression for Assigning Transparency using String Attribute

707
4
04-18-2019 07:11 AM
DanielKonzek
Occasional Contributor

I would like to be able to have point features show as 50 percent transparent if a field = 'no' and be displayed with no transparency if the same field = 'yes'.  I haven't been able to get this to work using a custom expression using the 'When' function and assigning the value of 50 to all features when the field value = 'no'.  Is there another way to accomplish this?

Current expression:  

var reviewed = $feature.Reviewed;
When(reviewed == 'Yes', '0', '50')

Thank you,

Dan

Tags (3)
0 Kudos
4 Replies
KenBuja
MVP Honored Contributor

Wouldn't you just set the transparency for the "No" symbol in the Change Style dialog?

The expression would be simply

$feature.Reviewed;

and in the Dialog, manually set the transparency.

Or if there is a direct way to set transparency through Arcade that I'm unaware of, I would expect it to use .5 instead of 50.

DanielKonzek
Occasional Contributor

Hi Ken,

  The layer about 30 different point types each with a custom symbol based on a 'feature type' field.  I need these custom point symbols to be 50% transparent if they have not been review and 0% transparent if they have been reviewed.  So I need to symbology to be based on two different fields - the first is the feature type' which dictates which custom symbol is used, and the second is 'reviewed' which dictates transparency level.

Thank you,

Dan

0 Kudos
KenBuja
MVP Honored Contributor

I was afraid it wouldn't be so easy

When I've had to symbolize several different fields on a single feature, I ended up adding the feature layer multiple times into the web map. Each layer would symbolize the points with a different field but they would have different sizes, so the same point would have overlapping symbols.

This map shows the sites that haven't been visited yet and whether they require water samples to be collected.

0 Kudos
DanielKonzek
Occasional Contributor

That's our current work-around also.  When an edit is made (no switched to yes), there is a lag between the replicated feature service and the change take about 20 seconds and multiple zooms to refresh the data.  I was just trying to figure something out that would make the change immediate.

Thanks again,

Dan

0 Kudos