I'm using ArcGIS Pro 3.1.3 and I will start out by saying I am a beginner with computer languages.
Currently, I am trying to write an expression for labels using Arcade. I can get the Else If statements to be valid expressions.
if ($feature.CTV == "C"){
return "City"
}
else if ($feature.CTV == "V"){
return "Village"
}
else if ($feature.CTV == "T"){
return "Township"
}
However, this is only one part of the Label. I need to add MCD_Name to the beginning to get an out put like Paris Township. When I try to add it:
$feature.MCD_NAME + TextFormatting.NewLine +
if ($feature.CTV == "C"){
return "City"
}
else if ($feature.CTV == "V"){
return "Village"
}
else if ($feature.CTV == "T"){
return "Township"
}
I get an Error stating its an Invalid Expression. Error on line 3. Reserved keyword used.
I tried adding parenthesis, quotations, brackets etc.. (again I am no expert on computer language) and nothing seemed to work. I looked at other examples and such but I could not seem to find this kind of scenario.
Thank you in advance!
Solved! Go to Solution.
What you'll want to do is to create a variable that holds the first part of your label and use that to append the city type
var output = $feature.MCD_NAME + TextFormatting.NewLine;
if ($feature.CTV == "C"){
output += "City";
}
else if ($feature.CTV == "V"){
output += "Village";
}
else if ($feature.CTV == "T"){
output += "Township";
}
return output;
What you'll want to do is to create a variable that holds the first part of your label and use that to append the city type
var output = $feature.MCD_NAME + TextFormatting.NewLine;
if ($feature.CTV == "C"){
output += "City";
}
else if ($feature.CTV == "V"){
output += "Village";
}
else if ($feature.CTV == "T"){
output += "Township";
}
return output;
Awesome! I appreciate your input, it worked like a charm!