Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem with group formula

Status
Not open for further replies.

busi1

Technical User
Dec 14, 2005
56
US
I'm new to crystal reports and I'm using crystal reports 2008 and Oracle 10g.
I created a group on the below formula.All the records should be displayed according to the logic in the formula.

if ((DateAdd('d',30,{table1.RECD_DATE}) < currentdate) or ({table2.DATE} < currentdate)) then "OverDue"

else if ( ( DateAdd('d',30,{table1.RECD_DATE}) > currentdate and month(cdate(DateAdd('d',30,{table1.RECD_DATE}))) = month(currentdate) )
or
( month(cdate({table2.DATE})) =month(currentdate) or month(cdate({table2.DATE})) > month(dateadd('m',1,currentdate)) )
) then "This Month"

else if ( ( DateAdd('d',30,{table1.RECD_DATE}) > currentdate and month(cdate(DateAdd('d',30,{table1.RECD_DATE}))) > month(currentdate) )
or
(month(cdate({table2.DATE})) > month(dateadd('m',2,currentdate))
) then " Next Month"
else "None"

The formula runs for only the first condition before 'OR' and rest of the records are displayed under a blank group which is because the formula failed.


 
Blanks usually mean a null value. You can test for this with Isnull. Formuals stop when they hit a null if you don't do this.

I'd also suggest you add an extra diagnostic detail line and display the data and also the formula. Checke that the formula works as expected before using it to group.

[yinyang] Madawc Williams (East Anglia, UK). Using Crystal 11.5 with SQL and Windows XP [yinyang]
 
//Check for Null values and place them in the None group

stringvar displayText;


if isnull({table1.RECD_DATE})= true then displayText:="None" else
(if ((DateAdd('d',30,{table1.RECD_DATE}) < currentdate) or ({table2.DATE} < currentdate)) then displayText:="OverDue"

else if ( ( DateAdd('d',30,{table1.RECD_DATE}) > currentdate and month(cdate(DateAdd('d',30,{table1.RECD_DATE}))) = month(currentdate) )
or
( month(cdate({table2.DATE})) =month(currentdate) or month(cdate({table2.DATE})) > month(dateadd('m',1,currentdate)) )
) then displayText:="This Month"

else if ( ( DateAdd('d',30,{table1.RECD_DATE}) > currentdate and month(cdate(DateAdd('d',30,{table1.RECD_DATE}))) > month(currentdate) )
or
(month(cdate({table2.DATE})) > month(dateadd('m',2,currentdate))
) then displayText:=" Next Month"
else displayText:="None")

dsiplayText;

Try this,I hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top