0

I am still fairly new to coding so please excuse what may be simple mistakes.

I am working in ArcMap 10.5 and have an Overhead Conductor feature layer that I need to label based on what field (Conductor A, Conductor B, Conductor C, Conductor N, Construction Statuse) says what.

For example:

If Conductor A contains a value and Conductor B and C contain 'N/A' then the label for Overhead Conductors should display what is in the Conductor A field.

If Conductor B contains a value and Conductor A and C contain 'N/A' then the label for Overhead Conductors should display what is in the Conductor B field, and so on.

HOWEVER, the twist comes in when 'Construction Status' field contains a 'Proposed' status instead of an 'Installed' status. When this field has a 'Proposed' status I would like the label to be displayed in a larger, bold font.

I have included the original labeling expression and the expression of when I added what I hoped would make the font appear larger and bold when a 'Proposed' status was displayed in the 'Construction Status' field. I have also included a screen shot of how the fields appear in the attribute table.

The label expression format I am using is done in VBScript.

If anyone knows of an easier way to accomplish this in a different script I am open to suggestions but I am unfortunately stuck due to my lack of coding experience.

ORIGINAL EXPRESSION

Function FindLabel ( [conductora], [conductorb], [conductorc], [conductorn] )
dim a
if [conductora] <> "" and [conductora] <> "NA" then
a = a &  [conductora] 
elseif  [conductorb]  <> "" and [conductorb] <> "NA" then
a = a &  [conductorb] 
elseif  [conductorc]  <> "" and [conductorc] <> "NA"then
a = a &  [conductorc] 
elseif  [conductorn]  <> ""and [conductorn] <> "NA" then
a = a &  [conductorn] 
end if
FindLabel = a
End Function

MODIFIED EXPRESSION

Function FindLabel ( [conductora], [conductorb], [conductorc], [conductorn] )
dim a

if [conductora] <> "" and [conductora] <> "NA" then
a = a &  [conductora] 
elseif  [conductorb]  <> "" and [conductorb] <> "NA" then
a = a &  [conductorb] 
elseif  [conductorc]  <> "" and [conductorc] <> "NA"then
a = a &  [conductorc] 
elseif  [conductorn]  <> ""and [conductorn] <> "NA" then
a = a &  [conductorn] 

elseif [CONSTRUCTIONSTATUS] = "Proposed" AND [conductora] <> "" and [conductora] <> "NA" then
a = a &  [conductora] 
FindLabel = "<BOL><FNT size = '12'>" + a &  [conductora]  + "</BOL></FNT>"
elseif  [CONSTRUCTIONSTATUS] ="Proposed" AND [conductorb]  <> "" and [conductorb] <> "NA" then
a = a &  [conductorb] 
FindLabel = "<BOL><FNT = '12'>" + a &  [conductorb] + "</BOL></FNT>"
elseif [CONSTRUCTIONSTATUS] ="Proposed" AND [conductorc]  <> "" and [conductorc] <> "NA"then
a = a &  [conductorc] 
FindLabel =  "<BOL><FNT = '12'>" + a &  [conductorc] + "</BOL></FNT>"
elseif  [CONSTRUCTIONSTATUS] ="Proposed" AND [conductorn]  <> ""and [conductorn] <> "NA" then
a = a &  [conductorn]

end if
FindLabel = a 

End Function

enter image description here

  • What software are you using? – Erik Mar 11 at 13:49
  • @Erik, the attribute table looks like an ESRI product – Taras Mar 11 at 14:16
  • I'm sorry I completely left that out. I am working in ArcMap 10.5 – AdLukas Mar 11 at 17:51
  • 1
    Are there records where A, B, and C are all "N/A" but N has a value? Your original if statement is written so that the N value would only be evaluated in that circumstance. – kenbuja Mar 11 at 19:26
  • Yes, I have a couple records where A, B, and C contain "N/A" so I would only need N value for those. – AdLukas Mar 11 at 19:39
1

Based off your current code, you could try something like this. It assumes that only one value from A, B, C, or N will be written out. As noted in my comment above, the only time the N value will be written is if A, B, and C are "N/A", which doesn't happen in your table view. Remember, an if statement will stop evaluating at the first time it is true. The rest of the elseif statements will not be evaluated.

Function FindLabel ( [conductora], [conductorb], [conductorc], [conductorn], [CONSTRUCTIONSTATUS] )
dim a

if [conductora] <> "" and [conductora] <> "N/A" then
  a = [conductora] 
elseif [conductorb] <> "" and [conductorb] <> "N/A" then
  a = [conductorb] 
elseif [conductorc] <> "" and [conductorc] <> "N/A"then
  a = [conductorc] 
elseif [conductorn] <> "" and [conductorn] <> "N/A" then
  a = [conductorn] 
end if

if [CONSTRUCTIONSTATUS] = "Proposed" then
  a = "<BOL><FNT size = '12'>" & a & "</FNT></BOL>"
end if
FindLabel = a 

End Function

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.