I have inspection dates to symbolize my locations. I was using the expression below and it works fine, but now I need to add another variable.
IIf(DateDiff(now(), $feature.dateauditperformed, 'years') < 1, "Inspected","2/3 Year")
Now I want those locations inspected within the last year = Current, >1 and <=2 years = Second Year, and everything else = Third year.
This is what I've been trying to work with. All I seem to get is "other".
var year = DateDiff(Now(), $feature.dateauditperformed,'years');
if (year <= 1) return 'Current';
else if (year > 1 && year <= 2) return 'Second Year';
else return 'Third Year';
end
Solved! Go to Solution.
Keep in mind that your conditions are evaluated in order, so you don't really need to include the "year > 1" on the second condition.
Also, when writing if statements in Arcade, you need to enclose the following command in brackets. And you don't need to put "end" on there.
var year = DateDiff(Now(), $feature.dateauditperformed,'years');
if (year <= 1){
return 'Current'
} else if (year <= 2){
return 'Second Year'
} else {
return 'Third Year'
}
But really, you could also accomplish this with a When function, too. It's more or less equivalent.
var year = DateDiff(Now(), $feature.dateauditperformed,'years');
return When(year <= 1, 'Current', year <= 2, 'Second Year', 'Third Year');
Try either one of those. Do you still get a response of "other"?
Keep in mind that your conditions are evaluated in order, so you don't really need to include the "year > 1" on the second condition.
Also, when writing if statements in Arcade, you need to enclose the following command in brackets. And you don't need to put "end" on there.
var year = DateDiff(Now(), $feature.dateauditperformed,'years');
if (year <= 1){
return 'Current'
} else if (year <= 2){
return 'Second Year'
} else {
return 'Third Year'
}
But really, you could also accomplish this with a When function, too. It's more or less equivalent.
var year = DateDiff(Now(), $feature.dateauditperformed,'years');
return When(year <= 1, 'Current', year <= 2, 'Second Year', 'Third Year');
Try either one of those. Do you still get a response of "other"?
I utilized the When statement with success. Thank you very much for your assistance!
Hi,
I am trying to do a similar thing. First I tried to symbolize it, no success and now I am trying to use the list widget.
I have a list of locations, each have a deadline for the project to finish ($feature.deadline).
I want to symbolize this in a list widget in the dashboard: deadline within a week, deadline withing a month, deadline within 3 months.
Is any of these even possible?
on the symbology in the map the result was always "else"
on the second in the list does not display nothing.
cheers
P