Select to view content in your preferred language

Label Class using Expression

507
2
09-26-2023 09:20 AM
Labels (1)
AnthonyHenager
New Contributor

I have been attempting label certain objects in a layer based on another field being populated or "NOT NULL". I am fairly new to ESRI and python and still learning and could use some assistance.

My attempt at a script is as follows:

def FindLabel ([STATUS], [FRSTDIVNO]):
     if ([STATUS]) IS NOT NULL:
         print ([FRSTDIVNO])

I am getting a syntax error:

Invalid Expression

File "<string>", line 2

if (esri_0) IS NOT NULL:

SyntaxError: invalid syntax

 

0 Kudos
2 Replies
DuncanHornby
MVP Notable Contributor

If you want assistance, it will help if you state which software you require assistance in as the syntax is applicable to ArcMap or ArcPro...

Edit your question, don't just simply reply to this as others then have to trawl through a pointless conversation.

ALSO format your code (via the 3 dots), its difficult to read and indentation is critical in python.

A question where you have put time and effort in formatting and providing all the required information gets answered a lot quicker!

0 Kudos
KenBuja
MVP Esteemed Contributor

You have to use None instead of NULL and put "is not" in lower case.

def FindLabel ( [STATUS], [FRSTDIVNO] ):
  if [STATUS] is not None:
    return ([FRSTDIVNO])

 

 

0 Kudos