Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Suppress Detail Section with Tier IF Statement Post Reply Post New Topic
Author Message
alrichar
Newbie
Newbie


Joined: 17 Jul 2012
Location: United States
Online Status: Offline
Posts: 5
Quote alrichar Replybullet Topic: Suppress Detail Section with Tier IF Statement
    Posted: 21 Dec 2012 at 7:21am
I am having an issue with this If Statment and was wondering if somebody could give me some advice on the best way to write this IF statement.
 
We have different products where our Data Entry team enters different rates for each day.  I am trying to develope a report that only shows locations where the one of the Mon - Sun rates are higher than they should be.  However, the report is only showing locations where all of the Mon - Sun rates are higher than they should be.  Can somebody explain to me what I am doing wrong in the IF statement?
 
Here is the code that I am putting in the Suppress Detail Section

IF {Product.Procduct} = "Product1" AND ({Rate.Monday} < .81 OR {Rate.Tuesday}< .81 OR {Rate.Wednesday} < .81 OR {Rate.Thursday} < .81 OR {Rate.Friday} < .81 OR {Rate.Saturday} < .81 OR {Rate.Sunday} < .21) THEN TRUE

Else IF {Product.Product} = "Product2" AND ({Rate.Monday} < 1.01 OR {Rate.Tuesday}< 1.01 OR {Rate.Wednesday} < 1.01 OR {Rate.Thursday} < 1.01 OR {Rate.Friday} < 1.01 OR {Rate.Saturday} < 1.01 OR {Rate.Sunday} < 1.01 ) THEN TRUE

ELSE IF ({Rate.Monday} < 1.50 OR {Rate.Tuesday}< 1.50 OR {Rate.Wednesday} < 1.50 OR {Rate.Thursday} < 1.50 OR {Rate.Friday} < 1.50 OR {Rate.Saturday} < 1.50 OR {Rate.Sunday} < 1.50 ) THEN TRUE

ELSE FALSE


Edited by alrichar - 24 Dec 2012 at 5:32am
IP IP Logged
shanth
Groupie
Groupie


Joined: 06 Aug 2012
Location: United States
Online Status: Offline
Posts: 75
Quote shanth Replybullet Posted: 21 Dec 2012 at 11:03am
I guess the third condition is overriding other two conditions irrespective of Product. It is saying: when Rate<1.5 then true else false. So your report shows all products with rate>1.5. If this is true, can you explain why you need third ELSE IF statement and what you are trying to accomplish.
IP IP Logged
alrichar
Newbie
Newbie


Joined: 17 Jul 2012
Location: United States
Online Status: Offline
Posts: 5
Quote alrichar Replybullet Posted: 21 Dec 2012 at 11:37am
Thank you for the response. I was initially thinking the same thing but it doesn't seem to be the issue. There is one location with a data entry error where the Tuesday Rate is 150 and the report is not picking it up since other days have a rate of .15.

The third Else IF is in there so that it captures all of the other products (These are constantly being added into our system). I took it out to see if the third Else IF was overriding the other two conditions. There are still locations that have Product1 with a Tuesday Rate (or other days) higher than the .81.

I guess this is my reasoning:

First Condition - Suppress Product1 if any Mon-Sun Rate is below .81
Second Condition - Suppress Product2 if any Mon-Sun Rate is below 1.01
Third Condition - Suppress all other products if any Mon-Sun Rate is below 1.50
Everything else Show
IP IP Logged
ctwriter
Newbie
Newbie


Joined: 23 Dec 2012
Online Status: Offline
Posts: 8
Quote ctwriter Replybullet Posted: 23 Dec 2012 at 9:35am
This might be a typo yet "where the Tuesday Rate is 150 and the report is not picking it up", it would not be picked up as the statement reads < 1.50

To view the rate of 150 update statement to > 100
IP IP Logged
alrichar
Newbie
Newbie


Joined: 17 Jul 2012
Location: United States
Online Status: Offline
Posts: 5
Quote alrichar Replybullet Posted: 24 Dec 2012 at 2:15am
Thanks for the reply.  Yes, my wording is a little bit confusing.  The statment is saying that if Mon, Tues, Wed, Thurs, Fri, Sat, or Sun rate < 1.5 then suppress the data.  Therefore, the only records that are showing are the incorrect rates that are >= 1.5.
IP IP Logged
alrichar
Newbie
Newbie


Joined: 17 Jul 2012
Location: United States
Online Status: Offline
Posts: 5
Quote alrichar Replybullet Posted: 24 Dec 2012 at 3:35am
I was able to get the statement to work but I used an AND clasue instead of an OR clause.  Ended up using a statement similar to this and it is pulling the data that I am looking for. 

IF {Product.Procduct} = "Product1" AND ({Rate.Monday} < .81 AND {Rate.Tuesday}< .81 AND {Rate.Wednesday} < .81 AND {Rate.Thursday} < .81 AND {Rate.Friday} < .81 AND {Rate.Saturday} < .81 AND {Rate.Sunday} < .81) THEN TRUE

Else IF {Product.Product} = "Product2" AND ({Rate.Monday} < 1.01 AND {Rate.Tuesday}< 1.01  AND {Rate.Wednesday} < 1.01  AND {Rate.Thursday} < 1.01  AND {Rate.Friday} < 1.01  AND {Rate.Saturday} < 1.01  AND {Rate.Sunday} < 1.01 ) THEN TRUE

ELSE IF ({Rate.Monday} < 1.50 AND {Rate.Tuesday}< 1.50  AND {Rate.Wednesday} < 1.50  AND {Rate.Thursday} < 1.50  AND {Rate.Friday} < 1.50  AND {Rate.Saturday} < 1.50  AND {Rate.Sunday} < 1.50 ) THEN TRUE

ELSE FALSE


Edited by alrichar - 24 Dec 2012 at 3:36am
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 28 Dec 2012 at 3:48am
<soapbox>
Because the various options of an If statement already evaluate to True or False and you're result is True or False, you don't really need the "if" statement.  It's redundant and can take longer to evaluate.  I would rewrite this as:
 
({Product.Procduct} = "Product1" AND ({Rate.Monday} < .81 AND {Rate.Tuesday}< .81 AND {Rate.Wednesday} < .81 AND {Rate.Thursday} < .81 AND {Rate.Friday} < .81 AND {Rate.Saturday} < .81 AND {Rate.Sunday} < .81))
OR
({Product.Product} = "Product2" AND ({Rate.Monday} < 1.01 AND {Rate.Tuesday}< 1.01 AND {Rate.Wednesday} < 1.01 AND {Rate.Thursday} < 1.01 AND {Rate.Friday} < 1.01 AND {Rate.Saturday} < 1.01 AND {Rate.Sunday} < 1.01 ) )
OR
({Rate.Monday} < 1.50 AND {Rate.Tuesday}< 1.50 AND {Rate.Wednesday} < 1.50 AND {Rate.Thursday} < 1.50 AND {Rate.Friday} < 1.50 AND {Rate.Saturday} < 1.50 AND {Rate.Sunday} < 1.50 )
 
This will evaluate to True or False and give you the value you're looking for.  Also, note where I put the parentheses - these are required to make this work correctly.
</soapbox>
 
-Dell
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.031 seconds.