I'm creating a dashboard for road signs. Each sign has the installation year (4 digit integer). (The field name is "Installation"). I want to show a pie chart that shows if signs are <10 years old, 11-20 years old, or >20 years old.
This is my first time trying to do this in a data expression, and I can't get the correct results. It says all the signs are 11-20 years old. I also realized the "ageyrs" variable says it's Nan. So something somewhere isn't calculating right. Can anyone spot what I need to fix in my code?
var p = 'https://www.arcgis.com';
var itemId = 'xyz';
var layerId = 0;
var fs = Filter(FeatureSetByPortalItem(Portal(p),itemID,layerID,['Installation']),'Installation > 0');
var ageyrs = Year(Now())-fs
var agechoice = iif(ageyrs>20,'>20 Years Old',(iif(ageyrs<10,'<10 Years Old','11-20 Years Old')))
var Dict = {
'fields':[
{'name': 'sign_age', 'type':'esriFieldTypeDouble'},
{'name': 'agecat', 'type':'esriFieldTypeString'}],
'geometryType':'',
'features':
[{'attributes':
{'sign_age':ageyrs,
'agecat':agechoice
}}]};
return FeatureSet(Text(Dict))
@XanderBakker