5 Replies Latest reply on Jul 23, 2014 9:11 AM by philmodjunk

    If/then calculation



      If/then calculation


           My first post ever to forum.   I've been reading and learning alot from other posts for years now.    I have a situation where I want set up a field to automatically enter an "X" in field "Vaccines on file and up to date" IF "Rabbies Vaccine Due Date" AND "DHPPC Vaccine Due Date" are greater than today.   So far I have:

           If ( Rabbies 1 & DHPPC 1 > Get ( CurrentDate ) )

           Is that much correct?   if so....what comes next?

           Thanks in advance!


        • 1. Re: If/then calculation

               & is the wrong operator and your basic syntax isn't quite there either:

               If ( Rabbies 1 > Get ( CurrentDate ) and DHPPC 1 > Get ( CurrentDate ) ; Value if True goes Here ; Value if False goes here )

               You can pick nearly any value you want for "value if True" if you want a regular check box format on your field. For a check box format, you have to define a value list so the value you specify in the value list for this check box is also the value you'd use for your If true result in the if calculation.

          • 2. Re: If/then calculation

                 Oh yes, and you'll need to click the "storage options" button and select the "do not store" option or this calculation will not update automatically as time passes.

            • 3. Re: If/then calculation

                   Pardon me for my next question....you will now see how "green" I am at this.

                   I entered:   If ( Rabbies 1 > Get ( CurrentDate ) and DHPPC 1 > Get ( CurrentDate ) ; Yes if true; No if false)

                   but when I hit "OK"   I get this message:   The specified field cannot be found.   I'm obviously missing something very fundamental.

                   So much appreciate your help with this!!!!


              • 4. Re: If/then calculation

                     The syntax for the if function is:  If (test ; resultOne ; resultTwo).  So, if 'test' is true (that is to say, if rabbies 1 > Get (current date) etc....) then the 'If' function will return whatever is in the place of resultOne.  In your case, it returns:

                     Yes if true

                     However, that phrase does not mean anything to filemaker.  That is why you are getting the error.  If you had instead used quotations marks, the function would then work.  However, it would literally return "Yes if true" when your test was true.

                     If you want the If () function to return the word "yes" when true, and "no" when false, then you would word it as so (for brevity's sake I won't retype your test):

                     If ( test ; "Yes" ; "No"). 

                     Just for clarity's sake, I want to point out that if you did not use the quote marks filemaker would look at the word yes and try to determine if that word yes was the name of a field or a function.  That is why filemaker said that the field could not be found.  So, if you DID have a field named 'yes if true', then filemaker would not return the phrase 'yes if true', rather it would return the contents of the field named 'yes if true'. 

                • 5. Re: If/then calculation

                       As Nihm has explained, I put in place holders for the true and false results as I did not know exactly what values you want to return in each case. You have to replace them with valid FileMaker expressions that return the value you want. You probably want:

                       If ( Rabbies 1 > Get ( CurrentDate ) and DHPPC 1 > Get ( CurrentDate ) ; "Yes"; "No")