Select to view content in your preferred language

Symbolizing off of a year

111
5
Jump to solution
Wednesday
AlexBeak
Emerging Contributor

Hello!  I'm using the online GIS platform and Field maps for sewer inspections.  I have a "Last Inspection Date Field" and i want to symbolize to show all pipes that have an inspection dates prior to 2025 or Blank as Red, and all pipes with an inspection year during or after 2025 as green.  

Can i do this using already existing symbology tools?  Or do i need to write an Arcade expression to create a new field?  (if the later, i will likely have more questions on how to wirte that)

 

Thanks!

0 Kudos
1 Solution

Accepted Solutions
Laura
by MVP Regular Contributor
MVP Regular Contributor

Arcade for sure! I still consider myself a newbie with it too, so it took me a minute for everything to click. My setup is a little different—I have it categorized as: No Inspection, Inspected in the Last 3 Months, Inspected in the Last 30 Days, and Inspected More Than 3 Months Ago.

// Get the most recent inspection date
var inspDate = $feature.Inspected_Date;

// If no date exists
if (IsEmpty(inspDate)) {
    return "No Inspection";
}

// Calculate difference in days between today and inspection
var daysSince = DateDiff(Now(), inspDate, 'days');

// Categorize
if (daysSince <= 0) {
    return "Inspected Today";
} else if (daysSince <= 30) {
    return "Last 30 Days";
} else if (daysSince <= 90) {
    return "Last 3 Months";
} else {
    return "More than 3 Months";
}
 
To make sure it’s using the most recent inspection, I have a related table that stores all inspections, with the inspection date auto-filled for each entry. I also have the main layer (hydrants) pull the latest inspection date from that table and overwrite the previous value. That way, the main layer only ever holds one date—the most recent one—and that’s the date Arcade uses.
 
Sometimes I go back and forth with chat gbt if I'm hung up.
 
Laura_0-1765398501322.png

 

View solution in original post

0 Kudos
5 Replies
RPGIS
by MVP Regular Contributor
MVP Regular Contributor

You would need to write an arcade expression in order for the symbology to change dynamically, especially for a date field.

Something like the example below should work.

var dt = $feature.InspectionDate
iif( !IsEmpty(dt) && Year(dt) < Year(Today()), 'Not Inspected', 'Inspected')

// if you plan on using multiple years
if( !IsEmpty(dt) ){
    When( Year(dt) == Year(Today()), 'Current', Year(dt) == Year(Today())-1, 'Last Year', Year(dt) == Year(Today())-2, 'The Year Prior', 'Old') }
AlexBeak
Emerging Contributor

Thank you!  I'm super green when it comes to writing these.  I think the first example you gave me is what i need, but i don't know what i need to change to make it work for my data.  Any additional info would be much appreciated! 

0 Kudos
EmilyGeo
Esri Regular Contributor

Hi @AlexBeak

One option using existing tools in the map is to create a copy of the layer, then apply separate filters to each one:

EmilyGeo_0-1765388887901.png

 

0 Kudos
Laura
by MVP Regular Contributor
MVP Regular Contributor

Arcade for sure! I still consider myself a newbie with it too, so it took me a minute for everything to click. My setup is a little different—I have it categorized as: No Inspection, Inspected in the Last 3 Months, Inspected in the Last 30 Days, and Inspected More Than 3 Months Ago.

// Get the most recent inspection date
var inspDate = $feature.Inspected_Date;

// If no date exists
if (IsEmpty(inspDate)) {
    return "No Inspection";
}

// Calculate difference in days between today and inspection
var daysSince = DateDiff(Now(), inspDate, 'days');

// Categorize
if (daysSince <= 0) {
    return "Inspected Today";
} else if (daysSince <= 30) {
    return "Last 30 Days";
} else if (daysSince <= 90) {
    return "Last 3 Months";
} else {
    return "More than 3 Months";
}
 
To make sure it’s using the most recent inspection, I have a related table that stores all inspections, with the inspection date auto-filled for each entry. I also have the main layer (hydrants) pull the latest inspection date from that table and overwrite the previous value. That way, the main layer only ever holds one date—the most recent one—and that’s the date Arcade uses.
 
Sometimes I go back and forth with chat gbt if I'm hung up.
 
Laura_0-1765398501322.png

 

0 Kudos
AlexBeak
Emerging Contributor

Thank you!

0 Kudos