Solved

How to display a result only if two fields meet a certain criteria

Posted on 2014-10-14
16
114 Views
Last Modified: 2015-01-06
Hi,

I am trying to create a formula that will only display results if one field is not equal to null and the other field is = to shipped. I am not quite sure on how to do this. How can I accomplish this?

Thanks
0
Comment
Question by:wayy2be
  • 7
  • 6
  • 2
  • +1
16 Comments
 
LVL 3

Accepted Solution

by:
prequel_server earned 250 total points
ID: 40381365
Select column1, column2, ...

FROM Table

WHERE

column1 IS NOT NULL

AND

column2='Shipped'
0
 
LVL 100

Assisted Solution

by:mlmcc
mlmcc earned 250 total points
ID: 40381409
In Crystal you can create a formula like

If IsNull({Table.field1})  AND {Table.field2} = 'Shipped'  then
    42

mlmcc
0
 

Author Comment

by:wayy2be
ID: 40383288
Thanks for the replies. I don't believe I stated the question correctly. If I needed a formula to only display records that had two attributes in common how can I accomplish this?  For example I want to display records for customers who are in our VIP club and who have purchased X product.  I apologize for the confusion.  Also I am very new to Crystal so if you can provide a step by step answer explaining where and how to insert the formula into the report that would be great.  Thanks so much.
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 40383477
Try this

Open the report
Click REPORT  --> SELECTION FORMULAS --> RECORD
Enter the formula

IsNull({Table.field1})  AND {Table.field2} = 'Shipped'  

Click SAVE AND CLOSE
Run the reort

mlmcc
0
 

Author Comment

by:wayy2be
ID: 40383487
Thanks for your reply. Actually I misstated the requirement, please see above.  Thanks.
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 40383533
That is what the record selection is for.

How do you determine membership in VIP club?

How do you know they ordered a product?

mlmcc
0
 

Author Comment

by:wayy2be
ID: 40383596
The table has a field for both and we would need to set it to be = to VIP and product X.
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 40384167
{VipField} = 'VIP' and {ProductField} = 'ProductName'

mlmcc
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:wayy2be
ID: 40393422
So just the following will list all records with both fields equal to VIP and Product Name?

{VipField} = 'VIP' and {ProductField} = 'ProductName'
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 40393542
It should.  Be sure to use your database field names in place of VipField and ProductField

mlmcc
0
 

Author Comment

by:wayy2be
ID: 40416559
Sorry I was away. No this does not work, returns no data.
0
 
LVL 34

Expert Comment

by:James0628
ID: 40417022
mlmcc's suggestion sounds good, but we don't really know anything about your data.  For one thing, you mentioned customers and products -- Are the customer and product fields that you're checking both in the same table, or separate tables?  If they're in separate tables, how are they linked?

 If mlmcc's suggestion didn't give you any records, what happens if you try each part separately?

 Try {field1} = "VIP" and see what you get, then try {field2} = "productX" and see what you get.  Obviously, replace the field names and values with your field names, and the values you're actually looking for.

 You are entering those tests in the record selection formula, correct?  For example, Report > Selection Formulas > Record.

 James
0
 

Author Comment

by:wayy2be
ID: 40434053
The fields are in the same table. I may not be explaining correctly. What I need is that if a field has VIP and another field has Product X then display those records that meet that criteria. For example VIP and Product B, no data is displayed.
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 40434269
Are they in the same record?

mlmcc
0
 
LVL 34

Expert Comment

by:James0628
ID: 40434281
If the two values that you're looking for are in the same record, then it really should be just as simple as the formulas that mlmcc and you posted earlier.  You should be able to just go to Report > Selection Formulas > Record and enter a formula like this:

{field1} = "some value" and {field2} = "some other value"

 If the fields could be null, you may need to test for that, but apart from that, it should be just that simple.  Which is why we keep asking these other questions (how many tables, are the values in the same record, and so on).  What you described seems pretty basic, so if it's not working, we're missing something.

 James
0
 

Author Comment

by:wayy2be
ID: 40484044
Sorry for the delay.  I will test it again and report back on Monday.  Thanks
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Problem Statement In an SAP BI BO Integration project when a BO universe is built on a BEx query, there can be an issue of unit & formatted value objects not getting generated in a BO universe for some key figures. This results in an issue whereb…
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

895 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now