Custom Label Expression in AGO

393
5
Jump to solution
03-25-2021 09:04 AM
Labels (3)
MCouden
New Contributor II

I have a field that has numbers and zeros. I want to label the the numbers as is but the zeros need to label as the word "pending". I know the start of the code is $feature(AADT_2020_Label) which will label the number. How do I make the expression if AADT_2020_Label equals zero label as pending? I've tried just putting pending in the text field but for some reason it is not liking it.

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
MCouden
New Contributor II

There's still an open parentheses in the return  feature with no closed parentheses. I took it out and it seems to be working. Thank you.

View solution in original post

0 Kudos
5 Replies
DavidPike
MVP Frequent Contributor

 

if ( $feature(["AADT_2020_Label"]  > 0) {
return $feature(["AADT_2020_Label"]
}
else {
return "Pending"
}

 

MCouden
New Contributor II

if  ($feature(["AADT_2020_LBL"] > 0)  {return $feature(["AADT_2020_LBL"]} else {return "Pending"}

I think there needs to be closed parentheses. I am getting the error of Parse Error:Line 1: Unexpected token {

0 Kudos
DavidPike
MVP Frequent Contributor

sure:

if  ($feature["AADT_2020_LBL"] > 0)  {return $feature(["AADT_2020_LBL"]} else {return "Pending"}
0 Kudos
MCouden
New Contributor II

There's still an open parentheses in the return  feature with no closed parentheses. I took it out and it seems to be working. Thank you.

0 Kudos
DavidPike
MVP Frequent Contributor

You're going to set the removal of an inadvertent parenthesis in the code I provided as the solution? :face_with_rolling_eyes:

0 Kudos