Using arcade to symbolize multiple attributes

577
4
Jump to solution
05-06-2020 01:20 PM
MichailaMusman
New Contributor III

Hi all, I have a short expression written to symbolize my points by last edit date when they are updated in the field. I'm also trying to symbolize by the year each point was created, which is specified in one my fields.  So what I'm trying to do is have each year be assigned a color, i.e. 2017 = yellow, 2018 = purple, 2019 = orange, and then have all three years change to one uniform color once they are edited by our field staff.  Here's what I have to change symbology by date edited. Any suggestions for including year edited in this? 

var water_date = $feature.EditDate;
var days_dif = DateDiff(Now(), water_date, "days");
var result = "water status";
if (days_dif <= 14) {
 result = "Complete";
} else if (days_dif > 14) {
 result = "Needs Water";
} 
return result;

Thanks!

0 Kudos
1 Solution

Accepted Solutions
XanderBakker
Esri Esteemed Contributor

Hi mmusman_CaseyTrees , 

If I understand you correctly, you probably could use the expression below that combines the creation year and the status that you already have:

var water_date = $feature.EditDate;
var create_date = $feature.CreationDate; // change to the fieldname in your data
var days_dif = DateDiff(Now(), water_date, "days");
var result = "water status";
if (days_dif <= 14) {
    result = "Complete";
} else if (days_dif > 14) {
    result = "Needs Water";
} 
result = Year(create_date) + " - " + result;
return result;

View solution in original post

4 Replies
XanderBakker
Esri Esteemed Contributor

Hi mmusman_CaseyTrees , 

If I understand you correctly, you probably could use the expression below that combines the creation year and the status that you already have:

var water_date = $feature.EditDate;
var create_date = $feature.CreationDate; // change to the fieldname in your data
var days_dif = DateDiff(Now(), water_date, "days");
var result = "water status";
if (days_dif <= 14) {
    result = "Complete";
} else if (days_dif > 14) {
    result = "Needs Water";
} 
result = Year(create_date) + " - " + result;
return result;
MichailaMusman
New Contributor III

Thank you Xander!  This worked perfectly.

XanderBakker
Esri Esteemed Contributor

Hi mmusman_CaseyTrees , 

I am glad it works. Could you mark the post that answered your question as the correct answer? Thanks!

0 Kudos
RenRosin
New Contributor III

I have a similar request. I need to symbolize valves on three fields, Valve type, Valve Position and Valve Exercise date. I've got an Arcade expression that groups the date into year, but I would love to add the Valve Type, and the Valve Position.

This is what my Arcade expression looks like:

var timestamp2021 = Date($feature.LASTSERVICE)
if (timestamp2021 >= Date(2021,01,01) && timestamp2021 < Date(2022,01,01)){return "2021-01-01 - 2022-01-01"}
var timestamp2020 = Date($feature.LASTSERVICE)
if (timestamp2020 >= Date(2020,01,01) && timestamp2020 < Date(2021,01,01)){return "2020-01-01 - 2021-01-01"}
var timestamp2019 = Date($feature.LASTSERVICE)
if (timestamp2019 >= Date(2019,01,01) && timestamp2019 < Date(2020,01,01)){return "2019-01-01 - 2020-01-01"}
else {return "Some earlier date range"}

Is this at all possible?

 

0 Kudos