I am setting up manhole points with multiple labels (Manhole Number, Rim Elev, Inverts, etc.). I want to know if there is any possible way to write an expression that will omit/remove Null or specific values (such as "0"). I have screenshots below and a copy of my expression.
Thank you in advance!
[ "MH#: " & [MH_ID] & vbNewLine & "RIM: " & [RIM_ELEV] & vbNewLine & "INV 1: " & [INV_1] & vbNewLine & "INV 2: " & [INV_2] & vbNewLine & "INV 3: " & [INV_3] & vbNewLine & "INV 4: " & [INV_4] ]
I can provide you an example of this using Python:
def FindLabel ( [NAME], [FCC] ):
if [FCC] == '0' or [FCC] == None:
return [NAME] + '\n' + [FCC]
The statement is saying if the value of field FCC equals 0 or NULL, return only the value of field NAME. Else, return NAME and the FCC field values. Here is an example using Pro:
Going through the labeling expression to do this will slow the labeling down, as each time it goes to label it runs the expression. The preferred way will be to narrow down what is labeled using a SQL query.
You can see in the screenshot below an example where there is a feature with a MyNumber value of 0 and one with a NULL value. The SQL query removes those and only the remaining features are labeled with the objectid field.
If you are not familiar with writing SQL queries please click the Help button on the dialog box and it will take you to the documentation - there are many examples included that will help you out with different scenarios.