Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Technical Questions
Message Icon Topic: help with formula Post Reply Post New Topic
Author Message
caldwek
Newbie
Newbie


Joined: 11 Apr 2008
Online Status: Offline
Posts: 5
Quote caldwek Replybullet Topic: help with formula
    Posted: 30 Jul 2009 at 11:26am
I "inherited" the position of admin'ing our reports.  We use a service management software, which I also admin.  We were using CR8.5 with an older version of the service management software.  We upgraded the service management software, and we had to upgrade CR as well...so we are using CR XI now. 
 
I've had to rebuild some reports because they didn't behave as before.  One particular report has this formula in record selection:
 
{probsummarym1.category} in ["HARDWARE","NOC"] and
{probsummarym1.open.time} in LastFullWeek and
((length(trim({probsummarym1.dil.problem.type}))>0) or
(length(trim({probsummarym1.dil.att.ticketno}))>0))
 
What's the purpose of the length(trim....?  What is its job?  I've looked within Crystal Help, but didn't get a good clarification on it.
 
-Ellisa
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 30 Jul 2009 at 11:37am
It is evaluating the field and verifying there is at least one character that is not a space.
trim removes any spaces from the beginning and the end of a field
trim("   Apple      ") ends up as "Apple"
Length just counts the number of characters in the field
IP IP Logged
caldwek
Newbie
Newbie


Joined: 11 Apr 2008
Online Status: Offline
Posts: 5
Quote caldwek Replybullet Posted: 30 Jul 2009 at 12:09pm
Ok.  Thank you.  It definitely helps me understand what the report is reporting on.
 
-Ellisa
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 30 Jul 2009 at 12:58pm
Most likely due to the fact that the sub report is laerady being filterd by a join to the main report or the data source is different in the sub report and the new report.
It only evaluates rows that the data source is going to bring into the report as a whole. Sub reports can also get filtered by the LINK between the main and sub reports (if one has been added)
IP IP Logged
caldwek
Newbie
Newbie


Joined: 11 Apr 2008
Online Status: Offline
Posts: 5
Quote caldwek Replybullet Posted: 30 Jul 2009 at 1:50pm

I figured out why they were displaying a different number of records.  It was a mistake on my part concerning the 2nd line.  I first referred to the formula from the main report.  The formula for the subreport is this:

{probsummarym1.category} in ["HARDWARE","NOC"] and
{probsummarym1.status} <> "closed" and
((length({probsummarym1.dil.att.ticketno})> 0) or
(length({probsummarym1.dil.problem.type})> 0))

With that said, the report should be showing a total of 150 records and it only shows 2.  It's almost as if only the first 3 statements are being read and (length({probsummarym1.dil.problem.type})>0 is being ignored.  I say this because when I query the first 3 statements within my service management system, I get the return of the 2 records the report is returning.  If I query the the whole statement without the (length({probsummarym1.dill.att.ticketno})>0 part in my system and within the report I get the same number of records returned...148. 
 
I seem to have this problem on a couple of other reports as well...the record selection formula seems to "ignore" the last part of the statement. 
 
There are no joins between the subreports...they report off of the same database and off of the same table probsummarym1.
 
Any ideas?
 
-Ellisa 


Edited by caldwek - 30 Jul 2009 at 1:51pm
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 30 Jul 2009 at 2:06pm
Most likely your issue is the AND between all of the parts.
It is evaluating to make sure that each row has category of Hardware of NOC AND any status other than closed AND either the ticketno or type has a value in it (because this OR statement has parenthesis around them).
It will evaluate each row and as soon as any one of these conditions is ot met it excludes that row.
So I am confused by your testing method. There reallya re only 3 statements. The "length({probsummarym1.dil.problem.type})> 0)" is a sub statement in the last statement.
Does this make sense?
IP IP Logged
caldwek
Newbie
Newbie


Joined: 11 Apr 2008
Online Status: Offline
Posts: 5
Quote caldwek Replybullet Posted: 31 Jul 2009 at 5:29am
Yes and no...because the report was working perfectly fine in CR8.5 and has been for years.  The only reason I'm "rebuilding" it is because it isn't now, since we upgraded. 
 
On this subreport, I'm wanting to view tickets that have a status other than closed, tickets that are in category HARDWARE or NOC, and the fields dil.att.ticketno or dil.problem.type are not NULL.  Those 2 fields are not usually on the same forms.  The dil.att.ticketno field is usually on forms with category NOC, and dilproblem.type is usually on forms with category HARDWARE...but they could be on other forms, too.
 
I'm not sure how I could re-word this formula to get my results.
 
I want to return rows that have either category AND either of those fields if they have value in them AND a status other than closed. 
 
I could care less about other HARDWARE or NOC tickets if those fields are blank.  I could care less about other tickets with those fields filled if they are not HARDWARE or NOC calls.  And, I don't care to see tickets that are closed.
 
-Ellisa


Edited by caldwek - 31 Jul 2009 at 7:28am
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 31 Jul 2009 at 8:01am

Just to be clear there is a difference between NULL and empty. To check for not NULL you can change it to this:

{probsummarym1.category} in ["HARDWARE","NOC"] and
{probsummarym1.open.time} in LastFullWeek and
(isnull({probsummarym1.dil.problem.type})=false or
isnull({probsummarym1.dil.att.ticketno})=false)
 
I would check each part of the formula to see the number of rows you get per item. If any of these conditions limit the row set it is the "issue" because each row has to meet all of the conditions.
{probsummarym1.category} in ["HARDWARE","NOC"]
How many rows?
{probsummarym1.open.time} in LastFullWeek
How many rows?
(isnull({probsummarym1.dil.problem.type})=false or
isnull({probsummarym1.dil.att.ticketno})=false)
how many rows?


Edited by DBlank - 31 Jul 2009 at 8:06am
IP IP Logged
caldwek
Newbie
Newbie


Joined: 11 Apr 2008
Online Status: Offline
Posts: 5
Quote caldwek Replybullet Posted: 31 Jul 2009 at 11:35am
What's the difference in NULL and empty in Crystal? 
 
I did check each part of the formula before I started this thread to see the number of rows I got per item. 
 
{probsummarym1.category} in ["HARDWARE", "NOC"] returned thousands.
 
When I added {probsummarym1.status} <> "closed" I got a little over 200.
 
Then when I added
((length({probsummarym1.dil.att.ticketno})> 0) or
(length({probsummarym1.dil.problem.type})> 0))
I got only 2 rows.  However, if I commented out the first half of this statement or switched the order of the statement I would get a return of the other 148.  I should have had a total of 150.
 
With the OR statement between dil.att.ticketno and dil.problem.type, wouldn't I get a return if either statement were true OR if both were true and if they are both false...then I'd get no return for them?  Shouldn't it return rows for each part of that statement if there are rows for each?  I thought the Xor looked for only one part of the statement to be true.  I need to see rows concerning both parts of that statement. 
 
It isn't.  I'm not trying to be difficult.  Just trying to understand and find a resolution to my problem. 
 
 
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 31 Jul 2009 at 11:56am
No worries. When I run into these kinds of issues I usually disect the formulas into individual pieces and see what is happening per condition, this includes running each part of that OR statement seperately.
The difference between an empty string and NULL is the same as any DB although how you have your Report Option and NULL value options handled can impact it.
a NULL Is more akin to the data does not exist and an emptry string is more like a space although technically that is not correct.
Searchig for an item=NULL will not include a field that has an empty string but looking for item that <> NULL will include an empty string.
You are correct that in the above statement the as soon as the formula finds either statement to be TRUE it should includes the row.
if you used XOR it would always evaluate both.
That being said I have had issues with how Crystal handles NULLs in some of my formulas, especially if I use IIF or switch() in the formula.
So...it may be failing when it is hitting a NULL in the first part of your OR and not checking the secord part of the OR which omits items it should include.
You can try this to see if it helps...
((isnull({probsummarym1.dil.att.ticketno})=False and (length({probsummarym1.dil.att.ticketno})> 0)) or
(isnull({probsummarym1.dil.problem.type})=False and (length({probsummarym1.dil.problem.type})> 0)))
 
 


Edited by DBlank - 31 Jul 2009 at 11:58am
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.