How can I write this Code Block as an Arcade expression
You are missing a couple of curly brackets. Each return statement needs to be enclosed by curly brackets. Also, you need to use a double equals sign when checking if something is equal to a value. A single equals sign is used for assigning variables.
if($feature.MAJOR_ST == 'Farm'){ return "No" } else { return "Yes" }
Refer to If - else | ArcGIS Arcade | ArcGIS Developers for info on if-else syntax.
Refer to Operators | ArcGIS Arcade | ArcGIS Developers for operators, which discusses = vs ==.
For straight forward if-else statements, arcade also has an IIF function, which can be a little easier to create:
IIF($feature.MAJOR_ST == "Farm", "No", "Yes")
Logical functions | ArcGIS Arcade | ArcGIS Developers
That worked!
Thank you so much!
Hi,
I tried looking for a solution in the link you provided but wasn't successful. What I am trying to do is write a simple Arcade expression to find all streets in my map with a Street type of Farm and return a value of "No" but if Street type is not = to Farm then return a value of "Yes".
This is all I can come up with but it doesn't verify
Can you help me with this?
I know just enough coding to stumble my way through an expression in VB. I have never used Arcade. I will try your link and see if I can find something. Thanks
https://developers.arcgis.com/arcade/ has all kinds of resources. Your question isn't very specific, though. Is there a particular part you're having trouble with?
Arcade follows many of the conventions of JavaScript, so familiarity with that will help.
// defining a function function myExpression(some_param) { // do something here return 'some value' } // an if-else block If (some_condition) { // do something } else if (another condition) { // do something else } else { // do this if nothing else worked }
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.