Select to view content in your preferred language

writing an expression

434
3
10-25-2023 02:48 PM
TristanBest
New Contributor

I'm trying to write an expression in arcade for labeling properties.

What I want to do is only label certain roads,

The criteria is the road type is equal to either "Highway" "Major Arterial" or "Minor Arterial"

I'm new to expressions so any help is appreciated!

0 Kudos
3 Replies
PROBERT68
Frequent Contributor

I usually use the Definition  Query to set within the layer and the copy two more times and change it to like this 

Definition  Query road type is equal to Major Arterial

For example : One layer  using "road type is equal to Highway"

copy and paste in the Contents and change again to like this  road type is equal to Major Arterial

Then again copy and paste the same layer and change to road type is equal to Minor Arterial

Then for each layer, you can set labels for each certain roads ...

and I think that is the easiest way to do it.

ZachBodenner
MVP Regular Contributor

However, you can do this with arcade if you want to. Something like this might work:

var highway = $feature.<attribute containing road type> = "Highway";
var majorArterial = $feature.<attribute containing road type> = "Major Arterial";
var minorArterial= $feature.<attribute containing road type> = "Minor Arterial";
var roadLabel = $feature.<Road Name Attribute>;

When(highway, roadLabel, majorArterial, roadLabel, minorArterial, roadLabel, "")

 

I don't know if that's the best way to do it but it should work.

jbcypreste
New Contributor III

Label pane > Class tab > SQL Query button

You don't need to properly write an expression, just select "Create a new expression" and it will give you the boxes to select which attributes you want labeled.

0 Kudos