2 Replies Latest reply on Sep 9, 2010 5:55 PM by LaRetta_1

    calc not working

    storywizard

      Title

      calc not working

      Post

      Hello:

      I have this calculationa and the last part does not work, I need the text to say "Complete", but it stays blank. Everything else works fine...

      Case (
      IsEmpty ( PartCompDate ) and IsEmpty ( PartDueDate ) ; "" ;
      IsEmpty (PartCompDate) and (PartDueDate ≥ Get (CurrentDate));"In Process";
               IsEmpty (PartCompDate) ; "Over Due" ;
               PartCompDate ≤  PartDueDate ; "Complete")

      Any ideas??

      Story

        • 1. Re: calc not working
          philmodjunk

          The most obvious thing to check is to make sure both PartDueDate and PartCompDate are actually of type date. (Either a date field or a calculation set to return date.

          The next thing to check is to confirm that PartCompDate and PartDueDate store the correct data and in the correct form. (If either is a calculation field, make sure the calculation returns the correct date and data type.)

           

          • 2. Re: calc not working
            LaRetta_1

            Hi storywizard :^)

            You've got the right thinking but your calculation must be checked 'Do not Store Calculation Results' in calculation Storage Options.  You can also drop the parenthesis I've highlighted. 


            IsEmpty ( PartCompDate ) and IsEmpty ( PartDueDate ) ; "" ;
            IsEmpty (PartCompDate) and (PartDueDate ≥ Get (CurrentDate));"In Process";
                     IsEmpty (PartCompDate) ; "Over Due" ;
                     PartCompDate ≤  PartDueDate ; "Complete")

            Some people say the extra parenth adds clarity but it is considered poor programming style (in all languages) and it actually forces additional evaluation needlessly. :^)

            Your first line can also be written as: not PartCompDate and not  PartDueDate

            The reason is because dates return numbers so ANY date would be boolean true and no date would be boolean false.  Therefore, 'not date' would mean it was empty and is a bit easier to write.  This applies to all of the IsEmpty() tests on your date fields.  Usually, if all fields in the calculation are blank, it will not evaluate anyway so your first line wouldn't even be necessary but since your last line tests for ≤, it would evaluate "complete" if both fields were empty and you didn't have the first test on both fields.