Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: IF showing only one result Post Reply Post New Topic
Author Message
Bozonutwork
Newbie
Newbie
Avatar

Joined: 08 Jun 2011
Location: Canada
Online Status: Offline
Posts: 3
Quote Bozonutwork Replybullet Topic: IF showing only one result
     Posted: 08 Jun 2011 at 4:48pm
I'm trying to make a report that will show a constant string for one condition and a field in a table for another condition.

Here is a example of the formula i'm using:

If {table1.Always} = 1 then "Always"
else
{table2.description}

The problem I come with is that i get the result but only for one of the condition. I run the report and get only the result that correspond to the else part. If i remove the else part, I get the result that correspond to the line that have 1 in the table1.always. I can never come up with the result i would like to appear:

Result1     Always
Result2     Description1
etc

Can someone help me please?

Thanks
IP IP Logged
CircleD
Senior Member
Senior Member
Avatar

Joined: 11 Mar 2011
Location: United States
Online Status: Offline
Posts: 251
Quote CircleD Replybullet Posted: 08 Jun 2011 at 5:56pm
Are you trying to get an either or statement or are you trying to get it to print both like the "result you would like to appear".Looking at what you've posted you're trying to get it to appear like the latter but you're using an either or statement to accomplish it.
IP IP Logged
Bozonutwork
Newbie
Newbie
Avatar

Joined: 08 Jun 2011
Location: Canada
Online Status: Offline
Posts: 3
Quote Bozonutwork Replybullet Posted: 09 Jun 2011 at 12:06am
I would like to print both depending of what is inside the field of the first table. If there is a certain value it will print the string. For other value in the first table it will print information from a second table.
IP IP Logged
yggdrasil
Senior Member
Senior Member
Avatar

Joined: 19 Jun 2007
Location: United Kingdom
Online Status: Offline
Posts: 150
Quote yggdrasil Replybullet Posted: 09 Jun 2011 at 3:38am
presumably there is a link between table1 and table2, an ID of some kind in the detail section.
Is your formula in the same section? It looks all right to me, but you could get what you are finding if it was in a footer?
 
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 09 Jun 2011 at 4:00am

do you have NULL values in the always field when it is not=1? If so change the formula to use default values for NULLs



Edited by DBlank - 09 Jun 2011 at 4:00am
IP IP Logged
Bozonutwork
Newbie
Newbie
Avatar

Joined: 08 Jun 2011
Location: Canada
Online Status: Offline
Posts: 3
Quote Bozonutwork Replybullet Posted: 09 Jun 2011 at 5:57am
I do have NULL values in the always field it is set to "use default values for NULLS". There is a ID that link the 2 tables yes.
I did a test to try my formula I change the else part to put a string like "test" instead of looking in another table field.
 
I get the result i want but with the string i've put
 
result1    always (value for this line is 1 in the table1)
result2    test      (value for this line is NULL in the table1)
result3    always (value for this line is 1 in the table1)
result4    test      (value for this line is NULL in the table1)
 
what i want it to show is the value in the table2 field. But as soon as i add the line to get this data i get (if i use the last example):
 
result2   description1
result4   description2
 
and i loose the information that would normally say "Always" as per my formula.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 09 Jun 2011 at 6:02am
when you add your line to get data from value 2 is the first use of any field from that table?
If so it likely means that using the value is enforcing your join at which point the record set is changing
 
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