Select to view content in your preferred language

Label expression depends on other field attributes condition

1533
5
10-17-2016 11:59 AM
UludağElektrik
Emerging Contributor

Hi,

I am looking to create a label expression that will result in the following: display 'Enabled', however if 'Enabled' is "False", display 'Status' label as "ALERT" .

 

Somethings like as below

Tags (1)
0 Kudos
5 Replies
TedKowal
Honored Contributor

Only one field is necessary?

Vbscript

Function FindLabel ( [Enabled] )

if [Enabled] = "False" then
  FindLabel = "ALERT"
else
  FindLabel = "Enabled"
end if

End Function

or

Python

def FindLabel ( [Enabled]  ):
   if [Enabled] == 'False' :
      return "ALERT"
   else:
      return "Enabled"
UludağElektrik
Emerging Contributor

Dear Ted, i really thank you. In fact you right i totally forgot, so yes i need also second one because when i applied that script on my map screen showing like as below.

So is there any way to just show if "Enabled" field is 'False' and when "Status" field is 'Normal' retention for 'Enabled' label. I do not want to show that Enabled label on the map because everything is allright.

thanks in advance.

0 Kudos
DarrenWiens2
MVP Honored Contributor

You can do it through code, like Ted mentions (return "" if you don't want a label), or set an SQL query to filter the features you want labelled.

TedKowal
Honored Contributor

Like Darren Wiens  mentioned filtering or modify my script above to return a blank string for the label (this happens when enabled is true -- actually it would happen if enabled is anything else except false)

vbscript

Else

   FindLabel = ""

---------------------------------

Python

    else:

        return ""

0 Kudos
UludağElektrik
Emerging Contributor

Thank you so much for every contributors

Cheers

0 Kudos