5 Replies Latest reply on Aug 30, 2013 3:32 PM by philmodjunk

    Help with a field calculation

    shae1725

      Title

      Help with a field calculation

      Post

           Hi

           Hope someone can help! I am trying to place a calculation in  field (A) but need help on how to compile.

            

           If (Window Width Metric > Window Height Metric; "L")

           or If (Window Width Metric  <  Window Height Metric;  "P")

            

           also if both the above fields above are empty I would like to insert text in the field (A)

           Thanks

            

            

        • 1. Re: Help with a field calculation
          philmodjunk

               And what should happen if the two fields are equal?

               

                    also if both the above fields above are empty I would like to insert text in the field (A)

               "insert" as in being able to directly enter data into the field?

               If I have that correct, you'll want something like this:

               Define a text field and give it an auto-entered calculation:

               Case ( IsEmpty ( Window Width Metric & Window Height Metric ) ; self ;
                           Window Width Metric > Window Height Metric; "L" ;
                           Window Width Metric  <  Window Height Metric;  "P")

               In most cases, you'll also want to clear the "do not replace existing values.." check  box.

          • 2. Re: Help with a field calculation
            shae1725

                 Hi

                 If Window Width Metric and Window Width Metric are empty I want my field to display "A"

                 No data will ever be directly enterd into the field.

                 Im assumming I could add   ( Window Width Metric =  Window Height Metric; "E")     if fields are equal

                 just out of interest what does "Case" mean

                  

                 Thanks

                  

            • 3. Re: Help with a field calculation
              philmodjunk

                   Case is a function that you can look up in FileMaker help. It's a more sophisticated version of an If function.

                   Then this field can be a field of type calculation:

                   Case ( IsEmpty ( Window Width Metric & Window Height Metric ) ; "A" ;
                               Window Width Metric > Window Height Metric; "L" ;
                               Window Width Metric  <  Window Height Metric;  "P" ;
                                "E" )

                   Select Text as your result type.

              • 4. Re: Help with a field calculation
                shae1725

                     Many Thanks for your time

                     Just one further question! You have added "E" at the end of the calculation without  ( Window Width Metric = Window Height Metric; "E")

                     I know it works, but can you briefly explain how the calculation knows its an =?

                      

                • 5. Re: Help with a field calculation
                  philmodjunk

                       Did you look up Case in Help?

                       Case uses a list of paired expressions separated by semi colons ;

                       The first expression in each pair is a bolean expression--it must evaluate to a result of either True or False and numeric results that are not zero or empty are also True and Zero/empty results are false. The second expression (The result expression) computes the result returned if the boolean expression that is paired with it is evaluated and returns True.

                       Case evaulates each boolean expression starting from the fist and then returns the value of the result expression paired with the first boolean expression that is True. You can then add one additional result expression to the end of the list (such as "E" ) and it will be returned if all of the boolean expressions evaluate to False. If you try different values out in your two fields, you'll find that the only case where all boolean expressions shown are false are when the two fields are = and not empty.