Table::Field = 0 yields 1 when Field is empty

I stumbled over a comparison result that looks odd to me:

The formula "Field = 0" yields 1 (True) when Field is empty and IsEmpty(Field) yields 1, too. Should be 0 (False).

When Field holds "0", the comparison yields 1, now correct.

Can someone shed light on this?

Demo file attached.test_comparison_to_zero.fmp12 (184 KB)

What it's returning is correct.

IsEmpty returns 1 when the field is empty and returns 0 when it contains something, regardless of what those contents are.

In your test of "Field = 0", because 0 is not quoted as a literal string it's checking two things: 1. is it empty & 2. Does it contain 0 as a number type data. Therefore leaving the field empty and putting a zero in it both return with a 1.

If you were to change your calculation to Field = "0", you would get your expected results. I added that field to your original file and have attached it. test_comparison_to_zero.fmp12 (180 KB)

5 Likes

Thank you, @PattyB. Couldn't get my head around this.

Using Exact ( table::field ; 0 ) will also yield the result you expect.

3 Likes

Why ist [Test = 0] equal 1 when I enter «x» in field [Test]? Thank

Louis

image

Is the field formatted as number? In that case x and no numeral is equal to 0, so true because test=0 looks for the numerical value

No, the field [Test] is a number field, but the field near [Test = 0] is not formatted. I understand that there is no number (just a letter «x») in a number field and so te field contains a ZERO ... right?

1 Like

Test=0 is a calculation. Therefore it takes the value of test and do its operation. The value of test is 0. (It doesn’t CONTAIN zero)

Therefore 0=0. Is true (1)

yeah, got it, thanks happy new year to all

Louis

1 Like

It has to do with test::test being a number field. Notice how the bottom two (text instead of number) both do not equal zero. So the numeric value of "x" is 0.

Screen Shot 2019-12-31 at 2.02.27 PM

2 Likes