Select to view content in your preferred language

Advanced Label Expression

942
2
09-01-2011 05:45 PM
RhiawnaBracci
Emerging Contributor
I am desperately trying to figure out how to NOT LABEL something. I have one field with all of my labels in it. The field is titled "As_Comment"

I have features such as pillars that I have data on and other structures but I don't want them to be labeled. When I try to just label a specific pillar to test my expression it works. However, when I try to use a wildcard (as there are many pillars ie pier 69, pier 70, pier 71, etc) the code is still verified and accepted but it still labels everything. I decided to go all out and see if I could NOT LABEL 2 items, messed up the code 😮 that was partially working and had to start all over again. Below is what I have at the moment after starting over again 🙂

Function FindLabel ( [AS_COMMENT] )
if [AS_COMMENT] <> ("PIER %")
then FindLabel  [AS_COMMENT]  =(" ")
else
FindLabel = [AS_COMMENT]
end if
End Function

Also, how would I write it if I didn't want to label 2 items? Say if I didn't want to label andthing with "PIER" in it AND anything with "CIP" in it?

Any speedy help on this is very much appreciated.
Tags (2)
0 Kudos
2 Replies
DavidWatkins
Esri Contributor
Hi Rhiawna,

Why don't you set up a label class with a SQL Query instead of doing this in a label expression? The SQL Query would be pretty simple:

"AS_COMMENT" NOT LIKE '%PIER%' AND "AS_COMMENT" NOT LIKE '%CIP%'

David
0 Kudos
RhiawnaBracci
Emerging Contributor
Hi Rhiawna,

Why don't you set up a label class with a SQL Query instead of doing this in a label expression? The SQL Query would be pretty simple:

"AS_COMMENT" NOT LIKE '%PIER%' AND "AS_COMMENT" NOT LIKE '%CIP%'

David


After much testing this is how it needs to be for SQL Query:

NOT "AS_COMMENT" LIKE 'PIER%' AND "AS_COMMENT" <> 'CIP' AND "AS_COMMENT" <> 'PRE'

The NOT has to be before the field for some reason. If you don't do it that way you'll get an invalid SQL statement error.

If you wanted it in VB then it'd be like this:
Function FindLabel ( [AS_COMMENT] )
  if instr( [AS_COMMENT], "PIER") = 0 and instr( [AS_COMMENT], "CIP") = 0 then
    FindLabel = [AS_COMMENT]
  end if
End Function


Thank you for your suggestion 😄
It's truly aggrivating that there isn't more ESRI help in this matter. I find it rediculous that it took several days and multiple people to figure out what should be so simple.
0 Kudos