Using Arcade to Display Multi Criteria Symbology

207
10
10-16-2019 01:17 PM
Highlighted
New Contributor II

Hi all!

So, I'm very new to the world of Arcade, and I'm trying to display data based off of two main attributes.

$feature.Status denotes if and when a point has been inspected. (i.e. Inspected - 2019 (Incomplete) )

$feature.tmpCondition denotes the quality of the point, ranging from poor to excellent.

I'm trying to develop a custom arcade expression to display this logic.

If status is "to be inspected", label as "to be inspected".

If tmpCondition is any of {poor, below minimum tolerable, unknown} AND status is any of {2017, 2018 complete, 2018 incomplete), label as "reinspect".

If tmpCondition if any of {poor, below minimum tolerable, unknown}, AND status is {2019 complete}, label as "inspected - 2019 (fail)".

If status is {2019 incomplete}, label as "Inspected - 2019 (Incomplete)". 

If status is any of {2019 complete, 2018 complete, 2018 incomplete, 2017}, label as "Inspected - 2019 (Pass)".

If it doesn't fit in any of these, label as "to be reviewed". 

Here's what I've got for code so far - I know well in advance it is not correct.

When( $feature.Status== ‘To Be Inspected’, ‘To Be Inspected’,

$feature.tmpCondition== ‘Poor’ || ‘Below minimum tolerable' || 'Unknown' && $feature.Status== ‘Inspected – 2017’ || ‘Inspected – 2018 (Complete)’ || ‘Inspected – 2018 (Incomplete)’, ‘Reinspect’

$feature.Status== ‘Inspected – 2019 (Complete)’ && $feature.tempCondition== ‘Poor’ || ‘Below minimum tolerable’, ‘Inspected – 2019 (Fail)’,

$feature.Status== ‘Inspected – 2019 (Incomplete)’, ‘Incomplete – 2019’,

$feature.Status== ‘Inspected – 2019 (Complete)’ || ‘Inspected – 2018 (Complete)’ || ‘Inspected – 2018 (Incomplete)’ || ‘Inspected – 2017’, ‘Inspected (Pass, 2019)’,

'to be reviewed' )

Thanks in advance, I'm really stuck here.

10 Replies
Highlighted
MVP Honored Contributor

You'd have to use syntax like this

($feature.tmpCondition == ‘Poor’ || $feature.tmpCondition == ‘Below minimum tolerable' || $feature.tmpCondition == 'Unknown') && ($feature.Status == ‘Inspected – 2017’ || $feature.Status == ‘Inspected – 2018 (Complete)’ || $feature.Status == ‘Inspected – 2018 (Incomplete)’), ‘Reinspect’‍‍‍
Reply
0 Kudos
Highlighted
New Contributor II

So, would this syntax be correct?

When( $feature.Status== ‘To Be Inspected’, ‘To Be Inspected’, 

($feature.tmpCondition == ‘Poor’ || $feature.tmpCondition == ‘Below minimum tolerable' || $feature.tmpCondition == 'Unknown') && ($feature.Status == ‘Inspected – 2017’ || $feature.Status == ‘Inspected – 2018 (Complete)’ || $feature.Status == ‘Inspected – 2018 (Incomplete)’), ‘Reinspect’

($feature.Status == ‘Inspected – 2019 (Complete)’) && ($feature.tempCondition== ‘Poor’ || $feature.tempCondition == ‘Below minimum tolerable’), ‘Inspected – 2019 (Fail)’,

$feature.Status == ‘Inspected – 2019 (Incomplete)’, ‘Incomplete – 2019’,

($feature.Status == ‘Inspected – 2019 (Complete)’ || $feature.Status == ‘Inspected – 2018 (Complete)’ || $feature.Status == ‘Inspected – 2018 (Incomplete)’ || $feature.Status == ‘Inspected – 2017’), ‘Inspected (Pass, 2019)’,

'to be reviewed')
Reply
0 Kudos
Highlighted
MVP Honored Contributor

A few minor revisions. You left off a comma on line 3 and I removed a few extraneous parentheses.

When( $feature.Status== ‘To Be Inspected’, ‘To Be Inspected’,

($feature.tmpCondition == ‘Poor’ || $feature.tmpCondition == ‘Below minimum tolerable' || $feature.tmpCondition == 'Unknown') && ($feature.Status == ‘Inspected – 2017’ || $feature.Status == ‘Inspected – 2018 (Complete)’ || $feature.Status == ‘Inspected – 2018 (Incomplete)’), ‘Reinspect’,

$feature.Status == ‘Inspected – 2019 (Complete)’ && ($feature.tempCondition== ‘Poor’ || $feature.tempCondition == ‘Below minimum tolerable’), ‘Inspected – 2019 (Fail)’,

$feature.Status == ‘Inspected – 2019 (Incomplete)’, ‘Incomplete – 2019’,

$feature.Status == ‘Inspected – 2019 (Complete)’ || $feature.Status == ‘Inspected – 2018 (Complete)’ || $feature.Status == ‘Inspected – 2018 (Incomplete)’ || $feature.Status == ‘Inspected – 2017’, ‘Inspected (Pass, 2019)’,

'to be reviewed')‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
Reply
0 Kudos
Highlighted
New Contributor II

Hi Ken,

The syntax appears to be working - but I'm receiving this error.

"The layer is not providing enough information to change the drawing style."

I'll open up a support ticket and hopefully that clears it up. Thank you for the help on the syntax!

Reply
0 Kudos
Highlighted
Esri Esteemed Contributor

Hi Daniel Zhang ,

How much data do you have in the feature layer you want to symbolize? Do all the situations occur? 

Reply
0 Kudos
Highlighted
New Contributor II

Hi Xander,

There's a decent amount of information in the layer. I'm not sure if all situations occur, especially since some of them are "true" given any of (a, b, c) matching with (x, y, z). Is the lack of some situations actually occurring the cause of the error? Is there anything I can do to keep this logic in place; as people will be editing the attribute data and I want the updated information to display properly. Thanks in advance!

Reply
0 Kudos
Highlighted
MVP Honored Contributor

I have a situation where I use Arcade to symbolize data that will be edited later. To properly create the legend I would edit the data so it would contain all possible combinations, make an insignificant modification to the Arcade code, and save the legend. Then, I would edit the data back to its default state.

Highlighted
Esri Esteemed Contributor

Hi Daniel Zhang ,

Since the error message you are receiving was pointing in that direction, I wanted to know, but the fact that not every class is represented in your data should not be a reason to generate the error. 

What Ken Buja  is suggestion is a good way to include all classes in your result. In the past I have "hacked" the json using AGO Assistant but that is not a recommended way (but necessary due to multiscale symbology based on the $viewscale of the map.

I noticed just now that you are using different types of quotes in your expression. Did the expression pass through Word or any other text editor? 

Can you try this (it's the same expression but without the wrong quotes):

When($feature.Status== 'To Be Inspected', 'To Be Inspected',
($feature.tmpCondition == 'Poor' || $feature.tmpCondition == 'Below minimum tolerable' || $feature.tmpCondition == 'Unknown') && ($feature.Status == 'Inspected – 2017' || $feature.Status == 'Inspected – 2018 (Complete)' || $feature.Status == 'Inspected – 2018 (Incomplete)'), 'Reinspect',
$feature.Status == 'Inspected – 2019 (Complete)' && ($feature.tempCondition== 'Poor' || $feature.tempCondition == 'Below minimum tolerable'), 'Inspected – 2019 (Fail)',
$feature.Status == 'Inspected – 2019 (Incomplete)', 'Incomplete – 2019',
$feature.Status == 'Inspected – 2019 (Complete)' || $feature.Status == 'Inspected – 2018 (Complete)' || $feature.Status == 'Inspected – 2018 (Incomplete)' || $feature.Status == 'Inspected – 2017', 'Inspected (Pass, 2019)',
'to be reviewed')
Reply
0 Kudos
Highlighted
New Contributor II

Hi Xander,

I tried out the code and it still popped out the same error as before. 

Hi Ken,

How would one edit the data to create all possible combinations? 

Also, thank you both for the help!

Reply
0 Kudos