Custom Expression Label in ArcGIS Online

149
2
3 weeks ago
Labels (3)
MCouden
New Contributor II

I know I'm close. 

If (DomainName($feature,"REVIEW_STATUS") = 1 or 3) then {return DomainName($feature,"TASS_REVIEW_STATUS")} = "Other")

I"m trying to have it label where If the Review Status is 1 or 3 then TASS Review Status = Other

1 and 3 are domains of review status and Other is a domain in the TASS Review Status field 

0 Kudos
2 Replies
KenBuja
MVP Honored Contributor

When using an If statement, you have to use "==" to compare two values.  You also have to use "||" when doing a this or that comparison. Finally, the code for "Other" goes inside the DomainName function. Your code should look like this

if ( DomainName($feature,"REVIEW_STATUS") == 1 || DomainName($feature,"REVIEW_STATUS") == 3) {
    return DomainName($feature,"TASS_REVIEW_STATUS", "Other")
}

 

XanderBakker
Esri Esteemed Contributor

Hi @MCouden ,

Values 1 and 3 do not sound like domain descriptions to me. I suppose they are the actual code values stored in the field. If that is the case you can do something like this:

if (Includes([1, 3], $feature["REVIEW_STATUS"])) {
    return "Other";
}

 I used the more or less new Includes function to shorten the validation and I am testing to the value stored in the field (the code in the domain). You may also want to include an else statement since otherwise, you will only see "Other" and nothing. Maybe something like this:

if (Includes([1, 3], $feature["REVIEW_STATUS"])) {
    return "Other";
} else {
    return DomainName($feature, "REVIEW_STATUS");
}

 

In the example, I return the text "Other" and not the description that corresponds to a code "other" from the domain you mentioned and Ken showed in his solution. If you need the description rather than the text "Other" you should use Ken's solution.