Arcade Label Expression: How to label an attribute if it contains a string?

766
3
03-17-2021 09:28 PM
Labels (3)
JustinOdell
Occasional Contributor III

Hi everyone,

I want to create a label expression which identifies if a string attribute contains a portion of text. If it does, return the value of that text.

e.g. In my head the logic must be something like...

If $feature.attribute Contains "text"

Return "text"

I'm sure its an easy answer, but I'm struggling to figure it out. Any help appreciated!

0 Kudos
3 Replies
JayantaPoddar
MVP Esteemed Contributor

Could you give an example of the input values and its expected output?



Think Location
0 Kudos
JustinOdell
Occasional Contributor III

Sure, 

The attribute in question contains strings. Sometimes the strings are single words, other times they are separated by a comma.

For example, attribute is "Number". Some features in the feature class will have the values in text such as "one" or "two" etc. And some values will be concatenated such that they read "one, two" or "three, four" etc.

I want to create a label expression so that any record containing a value of "one" is labelled as "one". If I have a string value of "one, two", then I simply want the label to return "one" as well.

Hopefully that makes sense.

0 Kudos
JayantaPoddar
MVP Esteemed Contributor

Check this out

var str=Find("ONE",Upper($feature.Attribute))
IIf((str>(-1)),"ONE","")

 

Jayanta_Poddar_0-1616071339833.png

 



Think Location
0 Kudos