Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

two fields comparison 1

Status
Not open for further replies.

needmoremoney

Technical User
Mar 30, 2005
123
0
0
US
Hi all,

I need help with this, hope someone can help. Thanks ahead of time.

I have two fields. CollumnA and CollumnB
I want to compare the values. If they are the same then I only want to output what is in field A. (If both are zeros then output blank".

If they are different, but if either field is a zero, then I want to output only the value that is not equal to zero.

If they are different, but neither values are equal to zeros then I want to output both values.

Sample data:

Field A Field B
1 1
2 2
3 3
4 0
0 5
0 0
3 6

OUTPUT SHOULD LOOK LIKE THIS:
1
2
3
4
5
(blank spot)
3,6

......

Thanks for any help.
 
if {table.fieldA} = {table.fieldB} then {table.fieldA} else
if {table.fieldA} = 0 then {table.fieldB} else
if {table.fieldB} = 0 then {table.fieldA} else
{table.fieldA} + "," + {table.fieldB}

Format the formula to suppress if zero (format field->number->customize->suppress if zero) to allow for the situation when they both equal zero. To leave the blank space, in the section expert, make sure that detail->suppress blank section is NOT checked.

-LB
 
hi try this

create formula like this
@Compare

if
field a = 0 and field b= 0
then
" "
else
if
field a = field b
then field a
else
if
field a = 0 or field b= 0
then
val field <> 0



Durango122
Remember to used all fingers when waving to policemen :)
 
I had something similar to lbass. But I'm getting the same error.

"A number, currency amount, date time, ofr data-time is required here."

Both of the fields are number fields (0.00).

Any ideas?

I'm using Crystal Reports 8.5.
 
this is exactly what I have:
........
If {tempreport1.jobcodereg}+{tempreport1.jobcodeot}=0.00 then
" "
else
If {tempreport1.jobcodereg}=0.00 then
{tempreport1.jobcodeot}
else
IF {tempreport1.jobcodeot}=0.00 then {tempreport1.jobcodereg};
............
 
You can't mix datatypes, and when I look at my first response, I realize I didn't adjust for that. Try this:

if {table.fieldA} = 0 and
{table.fieldB} = 0 then " " else
if {table.fieldA} = {table.fieldB} then
totext({table.fieldA},0,"") else
if {table.fieldA} = 0 then
totext({table.fieldB},0,"") else
if {table.fieldB} = 0 then
totext({table.fieldA},0,"") else
totext({table.fieldA},0,"") + "," + totext({table.fieldB},0,"")

-LB
 
Hey lbass,

That worked awsome! Thanks for helping me fix this problem. Hope you have a great day. Thanks again, you're always a big help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top