Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Filtering Data with a Formula Post Reply Post New Topic
Author Message
Chels2983
Newbie
Newbie
Avatar

Joined: 15 Jul 2009
Location: United States
Online Status: Offline
Posts: 5
Quote Chels2983 Replybullet Topic: Filtering Data with a Formula
    Posted: 20 Jul 2009 at 9:40am
I am trying to pull data from a field that contains both sample data and QC data.  I would like to have the sample data appear in the report and the QC data appear in the subreport.  I thought that I could use Select Expert to filter out the QC data for the main report, and then Select Expert to filter out the sample data for the subreport.  However, when using Select Expert for the main report, I receive an error that says something with regards to there being too much data or the formula being too complicated.  Thus, would it be better to create a formula myself?  And if so, I'm not exactly sure how to go about creating that formula. 
 
 
If ({FLATDATA_1.ACOD} = "TOC_") or ({FLATDATA_1.ACOD} = "%ASH_C") or, etc. 
then {FLATDATA_1.ACOD}
else . . . omit
 
Any help would be greatly appreciated.  
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 20 Jul 2009 at 9:59am
In this case for your select statement you do not need an if-then. Just use the TRUE condition for the items you want to be included:{FLATDATA_1.ACOD}} in ["TOC_","%ASH_C", "Next item here"] 
IP IP Logged
Chels2983
Newbie
Newbie
Avatar

Joined: 15 Jul 2009
Location: United States
Online Status: Offline
Posts: 5
Quote Chels2983 Replybullet Posted: 20 Jul 2009 at 11:57am
I tried this formula earlier.  However, when I insert it into my report, the field gives me a "True" or False" value when I need it to give me the actual data/field value.  
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 20 Jul 2009 at 12:13pm
Correct, it is a evaluating each row to see if it meets the condition (TRUE) or not (FALSE).
In your original post you indicated that you wanted a way to filter data using the select expert. I wrote the statement to be used in the select expert, not as a formula field.
I guess you are trying to use a formula field and then use that in the select statement which you can do but it really is adding in an extra step.
If you want to go down that rode then create a formula field as 'DataSelect' (or whatever you want):
if {FLATDATA_1.ACOD}} in ["TOC_","%ASH_C", "Next item here"]  then "Sample Data" Else "QC Data"
I may have uinverted the data types above so just switch the order if you need to.
In your select statement you can then use
{@DataSelect} = "Sample Data"
However this is the same thing as just making your select statement as:
{FLATDATA_1.ACOD}} in ["TOC_","%ASH_C", "Next item here"] 
 
IP IP Logged
Chels2983
Newbie
Newbie
Avatar

Joined: 15 Jul 2009
Location: United States
Online Status: Offline
Posts: 5
Quote Chels2983 Replybullet Posted: 20 Jul 2009 at 1:22pm
I think I understand now.  When I was using the Select Expert, I was trying to create a formula that would not include certain values within the field.; I continued to receive an error message stating that the "Expression is too complex."  However, the Select Expert works well with regards to creating a formula to include certain values.
 
Thank you so much for all of your help and suggestions.  It can be very frustrating trying to figure out what formulas to use and how to use them within Crystal.  I am so grateful for any help that you all have provided/continue to provide.   
 
 
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 20 Jul 2009 at 1:31pm
No problem.
With the select expert you are writing it to evaluate each row and then return a True or False for that row. 
If it =True it is included if it is False it is excluded.
 
The formula Fields in the Field Explorer can also be written to return true or false but is used for a lot more than that (like converting your data to some other more user friendly or readable format).
 


Edited by DBlank - 20 Jul 2009 at 1:32pm
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.000 seconds.