Arcade Expression for Assigning Transparency using String Attribute

1676
5
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
5 Replies
KenBuja
MVP Esteemed 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 Esteemed 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
nnolasco
New Contributor II

I just figured this out trying to do something similar based on a time constraint.

When setting your symbology;

* Define your Unique Symbols

* In Transparency click on "Attribute Values" and in the next window select "New Expression"

* Set your Transparency, in your example set the Low Values to 50

* Click the pencil to write your expression

I have included my screenshots as examples.  Based on what you wrote I think your expression would be something like 

IIf($feature.Reviewed = 'Yes', 0,1)

0 Kudos