Print Page | Close Window

Multiple Selection Criteria

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=17145
Printed Date: 26 Apr 2024 at 5:32pm


Topic: Multiple Selection Criteria
Posted By: HSD89
Subject: Multiple Selection Criteria
Date Posted: 27 Jul 2012 at 5:49am
Hi guys require some help, a little new to this forum so i hope ive posted in the correct part!
 
Im creating a report that will enable me to pick up flags raised on certain file numbers.
 
each file will have at least one flag, but some could have multiple flags. I want my report to say "if {cat.flag} has both "NST" and "PBS" then display "1 hour" and only count it once.
 
the problem im having at the moment is the report is showing an entry for the same file number twice (one for "NST" and one for "PBS")
 
can someone help me please? Im all out of ideas :(



Replies:
Posted By: DBlank
Date Posted: 27 Jul 2012 at 9:45am
group on the file nuber
create formula fields to convert your rows into 1 or 0 and then sum these at the group level to determin your text
//NST flag
if type=NST then 1 else 0
//PBS flag
if type=PBS then 1 else 0
 
for you 1 hour display
if sum(NST flag,filenumber)>0 and sum(PBSflag,filenumber)>0 then '1 hour'
place in group header or footer
suppress details.
as for counting create a Running Total and use an evaluate formula
 
name=PBSNSTCount
type=distinctcount
field=filenumber
evaluate = use f formula
sum(NST flag,filenumber)>0 and sum(PBSflag,filenumber)>0
reset=never
place in report footer


Posted By: amanda5615
Date Posted: 27 Jul 2012 at 9:49am
create a formula
Named Flag, inside that forumla
(if {cat.flag} = "NST" then 1 else 0) +(if {cat.flag} = "PBS" then 1 else 0)
Then create another forumla called HOURFLAG
If {FLAG} = 2 then "1 Hour"
I am sure there is an easier way to do this, but this is the quickest way I coudl think of.


Posted By: HSD89
Date Posted: 31 Jul 2012 at 3:32am
thanks for the input guys but still a little confused (please be patient, i am still finding my feet can you believe!)
 
i created a formula that looks like this :-
 
if {Category.Flag}= "NST" then "00:45" else
if {Category.Flag}= "SET" then "2:00" else
if {Category.Flag}= "NST" AND "PBS" then "1:00"
 
obviously the above will not work, but is there no way the change this forumla slightly to get it working?
 
many thanks in advance folks


Posted By: DBlank
Date Posted: 31 Jul 2012 at 3:55am
i assume you have 1 category per row in your data set and you can have any total number of rows per file (group).
you need to create 2 different formulas to see if each group has at least 1 row per group of NST and SET types.
 
//NST_flag
if {Category.Flag}= "NST" then 1 else 0
//SET_flag
if {Category.Flag}= "SET" then 1 else 0
 
create summaries for each of these a the group level
//NST Sum
sum(@NST_Flag,table.filenumber)
//SET sum
sum(@SET_Flag,table.filenumber)
now if each of these sums is > 0 then you have found a file (or group) that meets your conditions.
 


Posted By: HSD89
Date Posted: 31 Jul 2012 at 5:54am
DBlank thank you for your response. This has helped me to understand what i need to do!
 
How would i identify which of the cases have both an "NST" and "PBS" flag together?


Posted By: DBlank
Date Posted: 31 Jul 2012 at 6:18am

if you want to limit the report to only selecting those you would use group select criteria

if you want to a count you can use a running total - rt (or shared variable formulas
the rt version is
right click on Running Totals and select New
name=PBSNSTCount (or whatever you want)
type=distinctcount
field=table.lfilenumber
evaluate = use a formula
    sum(NST flag,filenumber)>0 and sum(PBSflag,filenumber)>0
reset=never
place in report footer
 



Print Page | Close Window