Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Or Function Post Reply Post New Topic
Author Message
blackfish
Newbie
Newbie


Joined: 08 Nov 2011
Online Status: Offline
Posts: 17
Quote blackfish Replybullet Topic: Or Function
     Posted: 25 Jul 2013 at 8:26am
I am using this formula in the subreport select expert to return a particular set of records.  I expected to get either the blue records or the red records, depending on what records are in the database.  However I get only the blue records before the black "or".   If I reverse the formula and and have the red statement first, it will return only red records.

Why is this formula not functioning the way I thought it would? 

({PRODUCTINFO.PartName} [1 to 4] = "Door" or {PRODUCTINFO.PartName} [1 to 6] = "DwrFnt") or
({PRODUCTINFO.PartClass} in ["DrawerFront", "Door"])

Thanks

STeve

IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 25 Jul 2013 at 9:21am
change the formula option to 'use default values for nulls'
IP IP Logged
blackfish
Newbie
Newbie


Joined: 08 Nov 2011
Online Status: Offline
Posts: 17
Quote blackfish Replybullet Posted: 25 Jul 2013 at 9:56am
That worked, thanks.  What is the logic behind using the option box?  Is this something that should always be checked?
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 25 Jul 2013 at 11:06am

Some of it depends on your data set and Crystal Report options set up.

Inside a formula if you do not state how to handle a NULL or set it to 'use defaults values' for nulls (in the formula editor or report set up) then the formula will stop evaluating and not return anything when it hits a null value. If you choose to use an isnull() in your formula to handle it is is imperative that this be the first condition otherwise it will stop evaluating on a NULL before it gets to that condition in the formula.
 
For example if X has some null values in it and you are not use default values for nulls these two formual will not return the same results
 
//good example
if isnull(x) then "A" else if x=1 then "B" else "C"
//bad example
if x=1 then "B" else if isnull(x) then "A" else "C"
IP IP Logged
blackfish
Newbie
Newbie


Joined: 08 Nov 2011
Online Status: Offline
Posts: 17
Quote blackfish Replybullet Posted: 25 Jul 2013 at 11:18am
Dan, thanks for the explanation.  I'll have to look in my data set to see where the null values would be.

STeve
IP IP Logged
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