Hi all,
I'm currently trying to write an expression to help code the color of pins for certan adresses with the rules as:
I wrote two seperate codes to work and each has some errors. I'm used to Python, but read through Arcade's documentation and couldn't find any help. My first attempt used multiple if functions, and the second used a when function.
The first:
if (($feature.Largest_Transaction_Amount) > 999 )
return ("Yellow")
var datef = Date ($feature.First_Transaction_Date)
var datec = Date ()
if DateDiff (datec, datee,"days") < (541)
return ("Blue")
var datel = Date ($feature.Latest_Transaction_Date)
if DateDiff (datec, datel, "days") > (729)
return ("Red")
else
return ("White")
and the second:
var datef = Date ($feature.First_Transaction_Date)
var datec = Date ()
var datel = Date ($feature.Latest_Transaction_Date)
When (($feature.Largest_Transaction_Amount) > 999, "Yellow",DateDiff (datec, datee,"days") < (541), "Blue",DateDiff (datec, datel, "days") > (719), "Red", 1=1, "White")
I understand there could be some kinks with the dating, but that is not the main issue. Any advice for the syntax or any other way to resolve either issue would be appreciated
(As a note, I prefer the second attempt, it could just be the novelty of a the function combining if and elif into a single function, but in the end I just need something that works)
Many thanks
You had some syntax problems in your first expression. Try something like this
if (($feature.Largest_Transaction_Amount) > 999 ) {
return "Yellow";
}
var datef = Date ($feature.First_Transaction_Date);
var datec = Date ();
if (DateDiff (datec, datee,"days") < 541) {
return "Blue";
}
var datel = Date ($feature.Latest_Transaction_Date);
if (DateDiff (datec, datel, "days") > 729) {
return "Red";
} else {
return "White";
}
I used my dataset with a date with this code as an example
var dateThen = Date($feature.Benthic_Date);
if (DateDiff(Now(), dateThen, 'days') < 40) {
return "Yellow";
} else {
return "Blue";
}
to get this map
And this is how it translated to using When
var dateThen = Date($feature.Benthic_Date);
When (DateDiff(Now(), dateThen, 'days') < 40 , "Yellow" , "Blue");