Forcing a feature value to load

03-01-2024 01:04 AM
Labels (3)
New Contributor III

Hello everyone while making a map with Arcade, i've encountered a problem

I have a DB with these fields:
city, year, pop2017, pop2018, pop2019...

Where pop{...} are fields that contain the population for the selected year (so pop2017 is the population of this city in 2017), many project work on this DB but each year, we need to make new maps selecting the right year;
I tried to make this a bit more automatized by using this:

`Current pop: ${$feature[`pop${$feature.year}`]}`

But, by doning this, it return me a NaN, after searching the root of this problem, i notice that i needed first to "load" these fields like so:

//$feature.year is currently at 2022

Console($feature.pop2022) // Here i force this field to load

$feature[`pop${$feature.year}`] //Here i call it


But, i'm now back at the same point, each year, i'll need to manually add the $feature.pop.... to force it to load

Does anyone know if there is a clever way to do this ? Like a way to force features fields to load without writing by hand a call on this field ?


Please guys, help me

2 Replies
Occasional Contributor II

@N0MAD , arcade expression doesn't seem correct to me. Could you explain this with screenshots like what data looks like and what is needed as an output? 

0 Kudos
New Contributor III

For instance i have these lines:


Each year, a new line will be added for each city, so for instance


But since this table is made from a view, each year, a new population survey is made so a new field is added to the table 'population', so the view will look like this:


(the database schema isn't very clever for me but it's a previous worker that made it)

So i need for each line to select the right population

$feature.year = the year of the pollution row
$feature.pop{20..} = one of the fields from the table population

The best way i find to get this (a way that i've made in many of my devs except Arcgis's) is to use the year value plus 'pop' to get the right field, that usually work but in Arcgis, it seems that the fields aren't loaded until i hard-code the key

0 Kudos