3 Replies Latest reply on Dec 13, 2014 10:11 AM by philmodjunk

    Why does this evaluate to 1?

    Kirk_1

      Title

      Why does this evaluate to 1?

      Post

      Why does the "if - exit" evaluate to one, if $count = 1 and $PortalCount = 5?

       

      Capture.JPG

        • 1. Re: Why does this evaluate to 1?
          jbante

          I know it doesn't look like it, but FileMaker variables are sensitive to data type. If either of your $Count or $PortalCount records contains the number as text instead of as a number, you can get unexpected results. This can be resolved by wrapping in the GetAsNumber function either when setting the variables, or when doing the comparison. Still, that usually manifests in conditions like "13" < "2" evaluating as True; with 1 and 5 both as text, the 5 is typically still be greater. I'm not entirely sure in this case, but using GetAsNumber may at least be worth a shot.

          • 2. Re: Why does this evaluate to 1?
            Kirk_1

            I've used this a lot and have never had this issue. But you're on to something...

            I'm populating this from a relationship.

            I just entered the get as number... it did not work.

            I entered in 8 as the $count with 5 still being the $PortalCount. It still did not work.

            When i pulled up the pop up to check the calculation, it "said" in the bottom... result must be text.

            Any other ideas? The other times i've used it are direct look ups or direct fields in the table. I'm learning more about the power of relationships and used one here to populate it.

            • 3. Re: Why does this evaluate to 1?
              philmodjunk

              In your calculation, you've written:

              $Count > $ProtalCount

              Note the misspelled variable name.

              If this expression evaluates as True, you'll get a numeric value of 1. If it is not True, you'll get a numeric value of 0.

              If you've misspelled a variable name, chances are that you'll be comparing a value to Nothing--what we call a "null value". And nearly any value will evaluate as greater than nothing as a null value is usually treated as zero in a calculation.