Select to view content in your preferred language

Zeros (0) in Model Builder

1378
6
Jump to solution
04-19-2023 11:44 AM
lah
by
Regular Contributor

I have a model that is using Get Field Value to return some number values from 2 fields in a feature class. It then passes those values into a Calculate Value tool that does some math to produce another number. I just ran into a scenario where one of the values in one of the fields was 0 and my model failed. After digging into it, I see that Model Builder is treating the zero as FALSE, and not doing any processing after that. 

I have the data type set to Double in Get Field Value, though it's still happening. Am I just stuck here or is there any way to get model builder to treat a zero like an actual number?

0 Kudos
1 Solution

Accepted Solutions
RhettZufelt
MVP Notable Contributor

I see what you mean.  Though, I can't say that it is passing False, as it doesn't seem to pass anything.  So, even though it reports it as value of 0, it will not even pass it to field calculator to test for null,zero, etc..

However, it seems that it WILL pass a 0 as a string:

RhettZufelt_0-1681939198730.png

Which then calculates back to a double field just fine, and will automatically cast it to double, even when it is 0.

R_

View solution in original post

6 Replies
RhettZufelt
MVP Notable Contributor

Putting 0 in the null value field works for me:

RhettZufelt_0-1681933105876.png

 

R_

0 Kudos
lah
by
Regular Contributor

That's what I had originally, but unfortunately still does not work; the end result is treated as FALSE instead of a number. I should have mentioned I am using Pro version 2.9.3

0 Kudos
RhettZufelt
MVP Notable Contributor

I am also in 2.9.3 as 2.9.4 on broke a bunch of the popup/attachment stuff.

I have tested with the above config using both a text input field and a double input field.  As long as I set it up in the Get Field Value tool as Double, with Null Value 0, it works as expected.

With 2 selected:

RhettZufelt_0-1681933869753.png

With 0 selected:

RhettZufelt_1-1681933888253.png

However, I don't see the dropdown option for Null Value as your image has.  Perhaps you have a domain on that field or subtype or something?

R_

 

 

 

0 Kudos
lah
by
Regular Contributor

I just typed in "null" to get it to try something else. Can you hook another tool to the end of the Get Field Value? The Get Field Value works, yes, but my issue is it not running anything afterwards because it thinks the output is false, and gives me the "The process did not execute because the precondition is false." thing.

RhettZufelt
MVP Notable Contributor

I see what you mean.  Though, I can't say that it is passing False, as it doesn't seem to pass anything.  So, even though it reports it as value of 0, it will not even pass it to field calculator to test for null,zero, etc..

However, it seems that it WILL pass a 0 as a string:

RhettZufelt_0-1681939198730.png

Which then calculates back to a double field just fine, and will automatically cast it to double, even when it is 0.

R_

lah
by
Regular Contributor

I can't believe I didn't try that. That did it - thanks so much!

0 Kudos