3 Replies Latest reply on Sep 16, 2015 8:40 AM by jlisburn

    Greater than/Less than calculating wrong

    sean.moore

      Title

      Greater than/Less than calculating wrong

      Post

      I'm ending up with a weird problem.

      I have two numbers in a return-delineated list. For some reason, FMP is calculating "greater than/less than" wrong. For instance, if my values are 10 and 7, it'll tell me that my first value minus my second is 3, but that the first value is NOT greater than the second. see the attached screenshot.DataViewer

      Any ideas what I'm doing wrong?

        • 1. Re: Greater than/Less than calculating wrong
          Jade

          Hi Sean,

          GetValue function returns a text result (and "10" is less than "7").  Use GetAsNumber function: GetAsNumber(GetValue(…))

          • 2. Re: Greater than/Less than calculating wrong
            raybaudi

            10 > 7 is false when those values are text type.

            So, the calc will be fair when you use something to transform the text to a number.
            The second expression, using a minus operator, tells to FileMaker to get a number result, but this isn't the case of your third expression.

            So, you could use:

            GetAsNumber ( GetValue( $$Var ; 1 ) ) > GetAsNumber ( GetValue( $$Var ; 2 ) )

            • 3. Re: Greater than/Less than calculating wrong
              jlisburn

              Thanks this helped me.

               

              In my situation the two comparatives were Number fields in (different) related tables.

               

              Filemaker would always evaluate incorrectly, even if I set my comparatives to variables.

               

              Only when I added GetAsNumber did the calc evaluate correctly.

               

              I wouldn't have thought that pulling data from an related table would negate it's field type (to text). Same goes for pulling the data into a variable.

               

              Learning comething new everyday - this one is a pain because I'm going to need to go through the whole solution to see if this '<' or '>' issue appears elsewhere.