Print Page | Close Window

true or false result

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Technical Questions
Forum Discription: Formulas, charting data, Crystal syntax, etc.
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=22217
Printed Date: 30 Apr 2024 at 5:30pm


Topic: true or false result
Posted By: crwzar80
Subject: true or false result
Date 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



Replies:
Posted By: DBlank
Date 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


Posted By: crwzar80
Date 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??


Posted By: DBlank
Date Posted: 01 Feb 2017 at 11:07am
I was using crystal syntax.
This returns an empty string?

{tblDocRigDocumenti001.rownum}=1 and {tblDocRigDocumenti001.Franchise} = 68


Posted By: crwzar80
Date 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.


Posted By: DBlank
Date 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


Posted By: crwzar80
Date 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.




Print Page | Close Window