5 Replies Latest reply on Feb 13, 2014 9:03 AM by Annette

# Calculation Help

### Title

Calculation Help

### Post

Hi,

I have a date field "Date1".  I have a seperate calculation field "Field1Text" which is going to be a difference in the current date and the date in Date1.

But,  I'm trying to put a little more in.  I want to say if Date1 is empty then "N/A", if Date1 is greater that the current date then "Future Date", then the difference between the Date1 and current date field otherwise.

I have a custom function for age which works great, it's:

Age ( Birth ; theDate ; Format )

So when I tried to create a calculation that was just the if blank show N/A otherwise give me the difference and it worked fine.  This was calculation:  If ( IsEmpty (Date1 ); "N/A"; Age (Date1 ; Get ( CurrentDate ) ; 3 ))

But when I try to add the extra step if date1 is future date it tells me I left something out.  Clearly I've just  written it wrong but not sure how.

I have:  If ( IsEmpty (Date1 ); "N/A"; (if (Date1 > Get(CurrentDate) ; "Future date"; Age ( Date1 ; Get ( CurrentDate ) ; 3 ))

Help!  lol

• ###### 1. Re: Calculation Help

Maybe take out the left parenthesis in front of the second IF command?

This:

..."N/A"; If (Date1 > Get(CurrentDate) ;

• ###### 2. Re: Calculation Help

Nope, still get the error message too many or not enough of either ( or )

Yet when I count i have the same number of each....just assume I have something in the wrong place or more than i need of something

• ###### 3. Re: Calculation Help

Strike that!!  Clearly I must have had a different error last time I tried it because it is working now when I do it without the ( before the second If. Thanks!!!

• ###### 4. Re: Calculation Help

Nesting the if functions makes this much harder to work with. Use Case instead:

Case ( IsEmpty (Date1 ); "N/A";
Date1 > Get(CurrentDate) ; "Future date";
Age ( Date1 ; Get ( CurrentDate ) ; 3 )   // "Else"
) // Case

• ###### 5. Re: Calculation Help

Thanks Phil!!