crystal-reportscrystal-reports-2011

Two conditions in crystal reports formula


I have a formula field for a date. It has the following formula that works

if ({cycle.accountProgram} in 
["071","089A","092A","dd45","Rebs21-1"]) 
then {cycle.entryDate} + 90 else {cycle.entryDate} + 30

we recently added a new column to the data base where if the entry to this column = "1" then formula field needs to read "Next Visit" if it's not "1" then it could proceed to the formula

this is what I tried

if {cycle.nextTarget } = "1" then "Next Visit" else
if ({cycle.accountProgram} in 
["071","089A","092A","dd45","Rebs21-1"]) 
then {cycle.entryDate} + 90 else {cycle.entryDate} + 30

crystal reports rejects it saying that the second "if" needs a string. what string would that be? (also, I should mention that cycle.nextTarget has no entries since it was just created. I don't know if that effects anything. moving forward the report will need to capture rows before and after it was created. so some will have that entry and and some will not. so those that lack that entry need to default to the original formula)

thanks


Solution

  • the results of an if then must all be of the same data type. Try this

    if {cycle.nextTarget } = "1" then "Next Visit" else
    if ({cycle.accountProgram} in 
    ["071","089A","092A","dd45","Rebs21-1"]) 
    then totext({cycle.entryDate} + 90) else totext({cycle.entryDate} + 30)