Select to view content in your preferred language

Arcade Expression Help

563
4
03-03-2022 10:32 AM
JasonCyphers
Frequent Contributor

I have an arcade expression symbolizing a feature (valve) and related table (valve inspection) join.

I created an arcade expression to symbolize on the map based on inspection date being within 14 months of today:

IIF(DateDiff(now(), $feature.InspectionDate, 'months') < 14, "Last Inspection Within 14 Months", "Last Inspection > 14 Months")

Works great, except it's symbolizing all the records (thousands of them) from the previous years.

Is there additional expressions I can include to only look at the most recent inspection date, and determine if that is within 14 months of "now"?

0 Kudos
4 Replies
MarcoPoetsch
Frequent Contributor

maybe something like this?

var DateDifference = DateDiff(Today(), $feature.InspectionDate, "month")
if (DateDifference <= 14){
    return 'Last Inspection Within 14 Months'
} 
else if (DateDifference > 14){
    return 'Last Inspection > 14 Months'
} 
else {
    return 'Not yet inspected'
}
0 Kudos
JasonCyphers
Frequent Contributor

Thanks for the reply!

That formula appears to return the same results as mine.

I need a way to only look at, and symbolize based on the most recent inspection date.  If it was inspected in 2020 and 2021, I only want it to look at the 2020 date to see if it is within 14 months of today.  Right now, it's looking at both years, and places two points on the map.

0 Kudos
MarcoPoetsch
Frequent Contributor

Hmm, in this case I think I would use the filter option in the web map to exclude all inspections older 14 months.

MarcoPoetsch_1-1646341775992.png

This is what I usual do to separate features based on date. If the inspections >14months are still important (for stats or whatever) you could make a copy of the layer and exclude/modify the filter expression.

0 Kudos
JasonCyphers
Frequent Contributor

That was my original plan, but I don't have that "in the last" option for some reason.

I am in Portal 10.8.1; so, I don't know if maybe Map Viewer (Beta) doesn't have that option in this version.  I see it in AGOL, but not in my Portal.

JasonCyphers_0-1646392274533.png

 

0 Kudos