Help calculating field with arcade using two other fields including date range

809
2
Jump to solution
02-17-2022 11:15 AM
AshleeWolf525
New Contributor II

I am new to Arcade and using ArcGIS Pro to calculate a field using an arcade expression.

I would like to calculate a field called "Eligiblity" with the domain "Eligible", "Not eligible", and "NA" based on two other fields: Status and Date.

There is one value in the "Status" field that I want to be classified as "NA" and three other values that are "Eligible for recollection" IF the event occurred more than 3 years ago and "Not eligible for recollection" if the event was within the last three years.

Basically as follows in plain English:

- If Status is Scouting return NA
- If Status is anything other than scouting (including SWSP Collection, Recollection SWSP, SOS Collection) and Date is before 12/31/2018, return Eligible
- If Status is anything other than scouting and Date is after 12/31/2018, return Not eligible


Here is what I have tried:

if($feature.STATUS is "Scouting") {return "NA"}
else if($feature.DATE <=Date(12/31/2018)) {return "Eligible for recollection"}
else {return "Not eligible for recollection"}

0 Kudos
1 Solution

Accepted Solutions
HuubZwart
Occasional Contributor

Very close, few pointers:

== is the syntax to check for equal to condition, not IS

Check syntax for date function, you need Date(2018, 12, 31)

Make sure the capitalization of attributes match (i.e. STATUS is not equal to Status)

Make sure your output matches your domains (Eligible for recollection vs Eligible)

View solution in original post

2 Replies
HuubZwart
Occasional Contributor

Very close, few pointers:

== is the syntax to check for equal to condition, not IS

Check syntax for date function, you need Date(2018, 12, 31)

Make sure the capitalization of attributes match (i.e. STATUS is not equal to Status)

Make sure your output matches your domains (Eligible for recollection vs Eligible)

AshleeWolf525
New Contributor II

Thank you! Those tips did the trick. The following is what I ended up with, if it's helpful to anybody in the future:

if($feature.Status=="Scouting") {return "NA"}
else if($feature.Date <=Date(2018,12,31)) {return "Eligible for recollection"}
else {return "Not eligible for recollection"}