Change feature color based on date

647
1
10-01-2020 10:08 AM
QuantaGIS
New Contributor

Specifically I am trying to change the color of my feature polygon based on its relation to today's date (if possible). The scenario is this: I am trying to track lease expirations for numerous properties. If a date from the attribute table (Lease Expiration date) is equal to or before today's date (the lease is expired) I would like the polygon color to change to black from red, green or whatever I decide it to be. 

Tags (1)
0 Kudos
1 Reply
JayJohnsonWashoeCounty
Occasional Contributor III

Yes, you can do this via a custom Expression in Symbology.

In the webmap, open symbology for the layer, in the attribute to symbolize, scroll all the way to the bottom of the list and create a custom expression.  The custom expression could be something like this:

// Symbolize by Expired

var age
var Expired


// Difference between feature attribute and today
age = DateDiff(Now(),$feature.ExpirationDate,'days')

//Is it expired or not?
Expired = iif(age<0, 'Not Expired','Expired')

//Sybolize on this value

return Expired

That should get you close to a solution.

Jay

Jay
Washoe County GIS