Print Page | Close Window

Formula to suppress fields based on two conditions

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Report Design
Forum Discription: The best way to design a report and problems you have encountered
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=13431
Printed Date: 04 May 2024 at 2:50am


Topic: Formula to suppress fields based on two conditions
Posted By: chengkeh
Subject: Formula to suppress fields based on two conditions
Date Posted: 07 Jun 2011 at 6:10pm
hi...
 
i am new here...
just wanna ask bout how to suppress when i have two conditions.
 
the situasion is like this.
i have a template that i designed which got
 
details g
details h
details i
details j
 
condition detail g which should suppress when
 
data type = '001' OR
data type = '002' OR
data type = '003' OR
data type = '004' AND
(create date >= ('2011-01-01')
 
condition detail h which should suppress when
 
data type = '001' AND
(create date >= ('2011-01-01')
 
condition detail i which should suppress when
 
data type = '001' OR
data type = '002' OR
data type = '003' OR
data type = '004' AND
(create date < ('2011-01-01')
 
condition detail j which should suppress when
 
data type = '001' AND
(create date < ('2011-01-01')
 
 
its actually
detail g VS I
detail h VS j
 
 
i did my code somthing like this, it shows that there is no error found
somehow it turn to show the detail g and i at the same time which i dont want that happen.it suppose to show only one, its  either g or i, based on the create date. Can somebody help me out...
 
detail g
=====
{SEB17L01.IN_ASM-NOTICE_ASM-TYPE_2} = "062" OR
{SEB17L01.IN_ASM-NOTICE_ASM-TYPE_2} = "064" OR
{SEB17L01.IN_ASM-NOTICE_ASM-TYPE_2} = "063" OR
{SEB17L01.IN_ASM-NOTICE_ASM-TYPE_2} = "166" OR
{SEB17L01.IN_ASM-NOTICE_ASM-TYPE_2} = "033" AND
{SEB17L01.IN_ASM-NOTICE_CREATE-DT_9} > = date (2011,01,01)
 
 
detail i
=====
if {SEB17L01.IN_ASM-NOTICE_ASM-TYPE_2} = "062" OR
{SEB17L01.IN_ASM-NOTICE_ASM-TYPE_2} = "064" OR
{SEB17L01.IN_ASM-NOTICE_ASM-TYPE_2} = "063" OR
{SEB17L01.IN_ASM-NOTICE_ASM-TYPE_2} = "166" OR
{SEB17L01.IN_ASM-NOTICE_ASM-TYPE_2} = "033" AND
({SEB17L01.IN_ASM-NOTICE_CREATE-DT_9} < date (2011,01,01))
then TRUE
   
 
 
 



Replies:
Posted By: FrnhtGLI
Date Posted: 08 Jun 2011 at 2:17am
Try some parenthesis around the OR statements to separate them from the AND. Also, you do not need an if/then in the suppression section as it already evaluates it that way. So something like:

detail g
=====
({SEB17L01.IN_ASM-NOTICE_ASM-TYPE_2} = "062" OR
{SEB17L01.IN_ASM-NOTICE_ASM-TYPE_2} = "064" OR
{SEB17L01.IN_ASM-NOTICE_ASM-TYPE_2} = "063" OR
{SEB17L01.IN_ASM-NOTICE_ASM-TYPE_2} = "166" OR
{SEB17L01.IN_ASM-NOTICE_ASM-TYPE_2} = "033")
 AND
({SEB17L01.IN_ASM-NOTICE_CREATE-DT_9} > = date (2011,01,01))
 
 
detail i
=====
({SEB17L01.IN_ASM-NOTICE_ASM-TYPE_2} = "062" OR
{SEB17L01.IN_ASM-NOTICE_ASM-TYPE_2} = "064" OR
{SEB17L01.IN_ASM-NOTICE_ASM-TYPE_2} = "063" OR
{SEB17L01.IN_ASM-NOTICE_ASM-TYPE_2} = "166" OR
{SEB17L01.IN_ASM-NOTICE_ASM-TYPE_2} = "033")
 AND
({SEB17L01.IN_ASM-NOTICE_CREATE-DT_9} < date (2011,01,01))


Not sure if this will get you the desired effect, but I know how Crystal can be when not separating the statements that way.

Hope that gets you somewhere.


-------------
|< /\ '][' ( )


Posted By: chengkeh
Date Posted: 08 Jun 2011 at 2:48pm

hi there,
i did try, but it didnt work.the samething happen like what i did.
thanx any way...

 
i did try this and i dont know whether its true as other people who have the same thing as me used to do it or what.but it works for now. 
 

1.in section expert for details, i write the date code

detail g-{SEB17L01.IN_ASM-NOTICE_CREATE-DT_9} >= date(2011,01,01)
 
detail h-{SEB17L01.IN_ASM-NOTICE_CREATE-DT_9} >= date (2011,01,01)

detail i-{SEB17L01.IN_ASM-NOTICE_CREATE-DT_9} <  date (2011,01,01)
 
detail j- {SEB17L01.IN_ASM-NOTICE_CREATE-DT_9} <  date (2011,01,01)

2.i create a blank subreport for every details section (details g,h,i,j) and write the data type code in sub report format.
 
detail g
 
{SEB17L01.IN_ASM-NOTICE_ASM-TYPE_2} = "062" OR
{SEB17L01.IN_ASM-NOTICE_ASM-TYPE_2} = "064" OR
{SEB17L01.IN_ASM-NOTICE_ASM-TYPE_2} = "063" OR
{SEB17L01.IN_ASM-NOTICE_ASM-TYPE_2} = "166" OR
{SEB17L01.IN_ASM-NOTICE_ASM-TYPE_2} = "033"
 
 
detail i
 
{SEB17L01.IN_ASM-NOTICE_ASM-TYPE_2} = "062" OR
{SEB17L01.IN_ASM-NOTICE_ASM-TYPE_2} = "064" OR
{SEB17L01.IN_ASM-NOTICE_ASM-TYPE_2} = "063" OR
{SEB17L01.IN_ASM-NOTICE_ASM-TYPE_2} = "166" OR
{SEB17L01.IN_ASM-NOTICE_ASM-TYPE_2} = "033"
 

3.in subreport tab, i check for the surpress blank subreport



Print Page | Close Window