Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

I am trying to create a formula field in crystal reports combining an if, then, else with an OR.  This seems as if it should be simple, but I am stumped.

Posted on 2008-10-07
9
Medium Priority
?
510 Views
Last Modified: 2012-05-05
I am trying to write a simple IF X or Y then Z else W statement in crystal and while it seems like it should be a simple thing, I cannot get it to work:

formula field ( GiftCount) Code reads:
if {Cash.Cash} > 0 OR
{Payments.Payment} > 0
Then 1
else 0;

a second field (Sum) reads:
sum({@GiftCount})

The problem is sum totals the 1's for all the records where Cash.Cash > 0 but does not include any 1's in the records where Payments.Payment > 0.  Using the built in summary field returns the same result leading me to assume that the field value is not being set to 1 for those later records.

What am I missing here???????
 
0
Comment
Question by:vtandi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
9 Comments
 
LVL 101

Accepted Solution

by:
mlmcc earned 200 total points
ID: 22663379
I suspect the problem is you have NULL values in the fields.

Try this
If Not IsNull({Cash.Cash})  AND {Cash.Cash} > 0  then
    1
else If Not Is Null({Payments.Payment}) AND {Payments.Payment}  > 0 then
    1
else
    0;

mlmcc
0
 
LVL 1

Expert Comment

by:sjjcat
ID: 22663621
Try:
if {Cash.Cash} > 0 Then 1
else
if {Payments.Payment} > 0 Then 1
else 0;
0
 

Author Comment

by:vtandi
ID: 22663751
Thanks sjjcat, I tried that one (Try:
if {Cash.Cash} > 0 Then 1
else
if {Payments.Payment} > 0 Then 1
else 0;)
and it did not work

mlmcc - I will try yours in the AM.  However, if I create the if/then without the OR (i.e. If Payments.payment >0 then 1 else 0;), it DOES count them as I would expect.  It is only when I add the OR that it seems to want to not work.  I think the fact that each part works individually would suggest that it is not the Null thing but rather something to do with the OR??????
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 1

Expert Comment

by:sjjcat
ID: 22663801
vtandi
Are you sure the payments field is a numeric field, not text? If text, it may not be able to identify > 0.
0
 

Author Comment

by:vtandi
ID: 22664015
Both Payments.payment
and Cash.cash are currency fields

-a
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 22664142
If Payments can be NULL when Crystal uses the field it stops execution and returns some value probably NULL or no value thus it doesn't count.

mlmcc
0
 

Author Comment

by:vtandi
ID: 22669373
mlmcc:

Thanks so much.  Just got back to this and your code did the trick.  Not sure why I have so much trouble writing Crystal formulas as opposed to Access or Excel....
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 22669395
Probably because of the way Crystal handles NULL values in a formula.

Crystal simply stops execution and doesn't really pass a value back.

mlmcc
0
 

Author Closing Comment

by:vtandi
ID: 31504001
Any general tips for an Advanced Excel and Access user who is finding Crystal formulas to be a painful experience (despite a large George Peck reference volume)?
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question