Select to view content in your preferred language

Using Arcade to dynamically symbolize points depending on time differences

1398
1
Jump to solution
05-10-2018 11:52 AM
JonathanSkloven-Gill
New Contributor III

I am trying to symbolize a map based on time elapsed from a field "DATE_ISSUE" to today (aka: Today()), where if the point is less than 6 months old, it is "active"; more than a year old, it is "expired"; between 6 months and a year, it is "old"; and if no date has been entered into "DATE_ISSUE", it is "pending"

I have a test record of 67 points. 24 have not been issued a date, 1 point is from December 8, 2016 (518 days old), 1 is from September 8, 2017 (244 days old), 1 is from May 12, 2017 (363 days old), the rest are from January 2018 onward.

I have this so far:

var pDate = Date(Today());
var rDate = Date($feature["DATE_ISSUE"]);
var age = DateDiff(pDate, rDate, 'days');
if (age < 182.5){
"ACTIVE"
}
else if(age >= 182.5 && age <355){
"OLD"
}
else if (age >= 365 && age < 10000){
"EXPIRED"
}
else if (age > 10000){
"PENDING"
}

This last else if clause is the result of a bank "DATE_ISSUE" field being calculated in the DateDiff function as 17,661.33

This gives me 40 "Active", 24 "Pending", and the three objects over 182.5 days old are simply gone. Literally.  My attribute table shows all 67. My symbology options, show a total of 64 points, and 0 in "other". When I check "other", the 3 show up, even though the count is 0. 

When I check the DateDiff Function, there are no values generated beyond 126  days, with the exception of the before mentioned 17,661.33. 

Just looking to visually flag expired or old points so office staff don't have to look them up

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
JonathanSkloven-Gill
New Contributor III

Update:

I ditched the prefix Date() when assigning variables. This solved the DateDiff Function giving 17,000+ as a result. It now flags them as "No Data". Perfect. 

As to the main issue: The 'older' points that go back beyond Jan 1 2018 were added online via the edit button on a MapViewer instance of the feature service. At no point during the first round that spawned the above did I save, close the map, and re-open it. It was just a scratch surface to test things out, so why save, right?... well... once I did, it worked as intended. 

SO. Even though your edits are Saved as you go, show up on the map with the attribute fields filled, and populated in the attribute table, it isn't really there to be calculated upon until you save, and refresh the MapViewer. Thanks...

View solution in original post

0 Kudos
1 Reply
JonathanSkloven-Gill
New Contributor III

Update:

I ditched the prefix Date() when assigning variables. This solved the DateDiff Function giving 17,000+ as a result. It now flags them as "No Data". Perfect. 

As to the main issue: The 'older' points that go back beyond Jan 1 2018 were added online via the edit button on a MapViewer instance of the feature service. At no point during the first round that spawned the above did I save, close the map, and re-open it. It was just a scratch surface to test things out, so why save, right?... well... once I did, it worked as intended. 

SO. Even though your edits are Saved as you go, show up on the map with the attribute fields filled, and populated in the attribute table, it isn't really there to be calculated upon until you save, and refresh the MapViewer. Thanks...

0 Kudos