I am labeling our power line span layer based on the conductor/wire type.

This information is located across three fields in the span layer which represent phases A,B,C.

Basically I want code that will:

Display conductor_a, 

if conductor_a is blank display conductor_b, 

if conductor_b is blank display conductor_c

I am unsure if python or VB would be better for this. Unfortunately I am having difficulty with entering python into the provided window. I've managed to make the following VB code

[gs_conductor_a] & vbCrLf & [gs_conductor_b] & vbCrLf &  [gs_conductor_c] 

This displays the conductor name, but might display up to three labels, which creates a large visual mess in some instances. I want to create a labeling system where there is only one label displayed per line segment. It is worth noting if more than one phase is populated the conductor is the same for all populated fields so anyone of the three will do, but it needs to display only one label total.

2 Answers 2


I'm not familiar with VB, but the following Python may do what you're after (with the 'Advanced' checkbox ON, and assuming a Shapefile where NULLs are not possible):

def FindLabel ( [conductor_a], [conductor_b], [conductor_c] ):
    if len([conductor_a]):
        return [conductor_a]
    elif len([conductor_b]):
        return [conductor_b]
        return [conductor_c]

If your feature class is in a geodatabase and not a Shapefile (so that it can contain NULLs and not just blanks), you can check for both NULLs and/or blanks instead of just checking for blanks (zero-length strings):

def FindLabel ( [conductor_a], [conductor_b], [conductor_c] ):
    if [conductor_a]:
        return [conductor_a]
    elif [conductor_b]:
        return [conductor_b]
    elif [conductor_c]:
        return [conductor_c]
        return ""
  • excellent thank you! This works exactly as I need it to. I was unsure how to format it in the labeling window as opposed to an IDE.
    – hmain
    Dec 9, 2019 at 21:41
  • 1
    Yep, ArcGIS is consistently inconsistent. Use "!" to delimit field interpolation in the Field Calculator (for Python), but "[" and "]" in the advanced labelling. Dec 9, 2019 at 21:42
  • In a database where Null is possible you can use if field == None and the reverse field != None to test for true null values in the python (more info stackoverflow.com/questions/3965104/not-none-test-in-python). From VB6/VBA in distant memory there was a function IsNull(field) to test for Null values (more info stackoverflow.com/questions/23273301/…). Dec 9, 2019 at 22:15

This may work as well:

def FindLabel ( [conductor_a], [conductor_b], [conductor_c] ):
    return [conductor_a] or [conductor_b] or [conductor_c] or "ANY VALUE IF ALL PRIOR FIELDS ARE EMPTY"
  • +1 Concise == good. No need in def I guess?
    – FelixIP
    Dec 10, 2019 at 3:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.