Select to view content in your preferred language

Arcade Expression for calculate a percentage

701
2
05-05-2023 01:15 PM
NaslyTatianaVargas
New Contributor

Hi!
I need help with an expression in an indicator. I have data population of Colombia and Bogota, this population is for many years (1790 - 2020). I need to calculate:

- first, the difference of population of Colombia between an initial year and a final year (I can did this)

- second, the difference of population of Bogota between an initial year and a final year (I can did this)

- third, the division between the second and first calculation in percentage.

I did this code but it isn´t work correctly. Please can you help me with this calculation?

Thank you so much

0 Kudos
2 Replies
jcarlson
MVP Esteemed Contributor

Your first featureset is grouped by Ano, and so is the second. So the second featureset is essentially going to be the same length as the first, but with a new calculated attribute.

Normally, summing for a percent wouldn't be ideal, but since there should only be one row per group in that ratio featureset, it ought to work. To format as a percentage, though, you'll want to multiply the result by 100.

Just curious, what results are you currently getting from your expression?

- Josh Carlson
Kendall County GIS
0 Kudos
drimit
by
New Contributor

Did it get it right?

Your Arcade expression looks correct, but you need to make sure that you are using the correct field type for your output field. It should be a text field since you are returning "yes" or "no". Also, make sure that you have selected the correct output field in the Calculate Field tool.

Here's an updated version of your Arcade expression:

kotlin

Copy code

var point = Geometry($feature);

var polygon_layer = FeatureSetByName($map, 'flood');

var polygons = Intersects(polygon_layer, point);

if (Count(polygons) > 0) {

return "yes";

}

else {

return "no";

}

Make sure that you select the output field as a text field and that you have the correct syntax in your model builder tool. You can use the Calculate Field tool to apply the expression to the point dataset.

If you're still having issues, double-check that the field names match exactly between the point dataset and the polygon dataset, and that the polygon dataset is loaded and visible in your map.

0 Kudos