Select to view content in your preferred language

Arcgis Coding Issue

293
7
Jump to solution
12-09-2024 02:18 PM
Labels (3)
SpencerThompson
Emerging Contributor

Hello, I'm very rusty with my Arcade abilities. Crash course: I have a table with 3 columns, I want my expression to take the values on 2 of them, divide them, and then put the result in a 3rd column.

The images attached are my attempt at this basic expression, and the error message that is thrown every time I try to run it. When I do the test one's, it says no errors and I'm stumped now. Any help is greatly appreciated!

0 Kudos
1 Solution

Accepted Solutions
SpencerThompson
Emerging Contributor

Solution: Double Check your data types before posting for help. I was trying to divide a Double by a String. Thanks for the help all!

View solution in original post

7 Replies

First thought: Does your dataset contain any null values in either the first or second column?  Does it contain any zeroes in the second column?

Try this modification to see if it works:

var numerator = $feature.B01003_001E;
var denominator = $feature.ALAND_SQKM;

if (IsEmpty(denominator) || denominator == 0)
{
  if (IsEmpty(numerator) || numerator == 0)
    return 0
  else
    return null
}

return numerator / denominator
------------------------------
M Reed
"The pessimist may be right oftener than the optimist, but the optimist has more fun, and neither can stop the march of events anyhow." — Robert A. Heinlein, in Time Enough for Love
AustinAverill
Emerging Contributor

This for sure - Usually if I have something like this in a pop up, I will output all results as text and create exception messages for those div/0 and NaN errors. 

0 Kudos
SpencerThompson
Emerging Contributor

Nope, same error message.

0 Kudos
AustinAverill
Emerging Contributor

Where are you attempting to implement this? What App?

0 Kudos
KenBuja
MVP Esteemed Contributor

What kind of table are you using this in? Is this in a Data Expression for a Dashboard?

0 Kudos
SpencerThompson
Emerging Contributor

This table is a hosted feature layer view. I have the population and the land area from 2017 and I'm trying to update the population value to 2022 in the pop density column. Then this data will be used in a dashboard once everything is set up.

0 Kudos
SpencerThompson
Emerging Contributor

Solution: Double Check your data types before posting for help. I was trying to divide a Double by a String. Thanks for the help all!