Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: true or false result Post Reply Post New Topic
Author Message
crwzar80
Newbie
Newbie


Joined: 26 May 2014
Location: Australia
Online Status: Offline
Posts: 5
Quote crwzar80 Replybullet Topic: true or false result
    Posted: 31 Jan 2017 at 3:01pm
Hi All, i am try to create a "TRUE/FALSE" formula to display a logo based on "Franchise" in ONLY the first row of data. there could be multiple rows of data and franchises as shown below.

Description    Row Number   Franchise      Qty
Filter                   1              68            1
oil                      2              13            5
plugs                   3              98            6

i used this formula until recently....

booleanVar S;
if PreviousIsNull ({tblDocRigDocumenti001.rownum}) then if
{tblDocRigDocumenti001.Franchise} = 68 then
S:=True
else
        S
Else
   S

this formula only looked at "Row 1" then checked the franchise, and returned True or false.

"WE" have recently added another row of data which is now "Row-1" so the "PreviousIsNul" no longer is valid and has screwed up this formula.

any help would be greatly appreciated.

Regards Wayne
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 01 Feb 2017 at 2:53am
You seem to be saying that you have a column called rownum as an integer type and you are not using the special field n crystal as recordnumber.
The previous seems unnecessary unless you have multiple rows with the value of 1 and you only want the first one. YUO should just be able to use this:
{tblDocRigDocumenti001.rownum}1 and {tblDocRigDocumenti001.Franchise} = 68

If you need to stick with what you had and your rownum is your sorted on field you could try:

if Previous({tblDocRigDocumenti001.rownum}) = -1 and
{tblDocRigDocumenti001.rownum} = 1 and{tblDocRigDocumenti001.Franchise} = 68 then
S:=True
IP IP Logged
crwzar80
Newbie
Newbie


Joined: 26 May 2014
Location: Australia
Online Status: Offline
Posts: 5
Quote crwzar80 Replybullet Posted: 01 Feb 2017 at 10:43am
Hi DBlank and thanks for the quick response.

i did not write the original formula but as i understand it, the way it was written was to "force" crystal to only look at the FIRST line, then read the franchise.

i have substituted "recordnumber" and the result is still false (in the case below should be true)
EG: booleanVar S;
if recordnumber = 2 and
{tblDocRigDocumenti001.franchise} = 68 then
S:=True
else S;

i have also tried both of your suggestions above and both return a "blank" field??
EG: the field is set to "boolean Text: true or false" but when run results in neither a true or false result??
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 01 Feb 2017 at 11:07am
I was using crystal syntax.
This returns an empty string?

{tblDocRigDocumenti001.rownum}=1 and {tblDocRigDocumenti001.Franchise} = 68
IP IP Logged
crwzar80
Newbie
Newbie


Joined: 26 May 2014
Location: Australia
Online Status: Offline
Posts: 5
Quote crwzar80 Replybullet Posted: 01 Feb 2017 at 11:51am
i think i see were the confusion is...
the logo is in the page header which is were the formula needs to be.

if it is at line level it works fine, (for line 1 and "68") however at page header level it is reading ALL lines which is (i think) why i keep getting the "FALSE" result.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 02 Feb 2017 at 2:28am
So you want to know for the entire data set that if record for rownum 1 has a franchise of 68 and display an image in the page header?
As long as you have no groups try adding a formula as
//LogoFind
if {tblDocRigDocumenti001.rownum}=1 and {tblDocRigDocumenti001.Franchise} = 68 then 1 else 0

sum this formula and use the result for your suppression
SUM(@LogoFind)=0

Edited by DBlank - 02 Feb 2017 at 2:29am
IP IP Logged
crwzar80
Newbie
Newbie


Joined: 26 May 2014
Location: Australia
Online Status: Offline
Posts: 5
Quote crwzar80 Replybullet Posted: 02 Feb 2017 at 1:23pm
DBlank you are a genius.. whilst i havent used the above exactly you have made me think "outside" the box.
the form can have several franchises or only 1, so what i have done is this.

on each line i have assigned a value based on the actual franchise EG:
if {tblDocRigDocumenti001.rownum}=1 and {tblDocRigDocumenti001.franchise} = 6 then 6 else
if {tblDocRigDocumenti001.rownum}=1 and {tblDocRigDocumenti001.franchise} = 15 then 15 else
if {tblDocRigDocumenti001.rownum}=1 and {tblDocRigDocumenti001.franchise} = 52 then 52 else 0

then in the Page Header i have this EG:
Sum ({@Franchise})
which will return a value ONLY from line 1 based on the formula above.

i then suppress each logo that does not equal that value...

Not what i would class as pretty but its working.

Many Thanks for you assistance DBlank.

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.016 seconds.