Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: CR Select Expert Post Reply Post New Topic
Page  of 2 Next >>
Author Message
Tupacmoche
Groupie
Groupie
Avatar

Joined: 04 Apr 2007
Online Status: Offline
Posts: 52
Quote Tupacmoche Replybullet Topic: CR Select Expert
     Posted: 06 Nov 2013 at 3:19pm
My question is how I can filter in the CR select expert based on the outcome of a formula field. The formula field simply performs a distinct count on a database field. If it is equal to  1, I want to suppress some records in the report otherwise do something else. The expression that I made in the formula field does not even show up in the list of expressions when I open up the select expert in Crystal.


Edited by Tupacmoche - 06 Nov 2013 at 3:38pm
Rob
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 07 Nov 2013 at 4:04am
you can use this as a group select option but not a record select and exclude an entire group based on the group summary result.
Note that group select happens in a later pass so technically all of the records are still in the report. When you create other summary reults it will include all of the records. YOu will have to use running totals or variable formulas to get summary data after the group select is applied.


Edited by DBlank - 07 Nov 2013 at 4:04am
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 07 Nov 2013 at 4:59am
and while it is off topic for the original post...

if you could create a stored procedure, you should be able to do all your filtering there and not even have to bother with the CR select expert.

just a thought, which I realize may be no solution at all.
IP IP Logged
Tupacmoche
Groupie
Groupie
Avatar

Joined: 04 Apr 2007
Online Status: Offline
Posts: 52
Quote Tupacmoche Replybullet Posted: 07 Nov 2013 at 8:38am
I would like to re-state the question since it may not have been clear. In the Select Expert you can do this:

   myfield <> 99

This is very simple, if myfield is equal to 99 the record will be left out. That is all, I want to do but only if a separate expression that counts values returns one (1), If it returns two (2) or more I want to do something else. So, can you do something like

If CFR_CNT = 1
then
       myfield <> 99
else
       someotherthing.


Rob
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 07 Nov 2013 at 8:57am
can you be more specific?
in general you should not use if-then in a select statement as it is really a boolean evaluation of a row to include (true) or exclude (false). The if-then is not needed.
a distinct count of a field is referencing your entire data. you have to pull the entire data set in to get the count which means you cannot also exlcude rows based on that result. If you did it would alter your original result thereby changing your exclusion condition as well.  
What is your end game?
IMO Lockwelle's solution is likley what you want (a stored proc or a command) but if you explain your desired result perhaps there is another crystal option to get you there.


Edited by DBlank - 07 Nov 2013 at 8:59am
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 07 Nov 2013 at 9:01am
another way to say what DBlank is saying...
you need to read all the rows in the data to determine if the formula result is true or false...BUT you want to exclude records based on the formula (which cannot be evaluated until all records have been read into the report)

you are in a catch-22

DBlank correct me if I am wrong
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 07 Nov 2013 at 9:13am

Thumbs%20Up

IP IP Logged
Tupacmoche
Groupie
Groupie
Avatar

Joined: 04 Apr 2007
Online Status: Offline
Posts: 52
Quote Tupacmoche Replybullet Posted: 07 Nov 2013 at 11:11am
Sorry, but the use of if-then example was not meant as a way of implementing the requirement but just to explain it. Now, I will be more specific as you requested.
I use the Formula Field below to determine how many worker were involved on a job.

 DistinctCount ({MeterSessionOutput.WokerID},{WorkSet.WorkSetID})

The above expression will return 1 or more representing the number of workers for a given work set. It was discovered that certain types of records should be filtered out depending on the number  of workers involved. So, if the above expression evaluates to one (1), I want the following filter in the Crystal select expert:

                        myfield <> 99

Now, the question is how to implement it.
Rob
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 07 Nov 2013 at 11:17am
probably your best bet is a stored procedure (ok, it is always going to be my first recommendation)

the other option is to create a command object that links the number of workers to a job. something like:
select sum(table.workers) as workers, table.jobid from table group by jobid.

now in the report you can link the 2 tables, the table and the command and finally in your record selection you can check what the numbers of workers was and respond accordingly.

in a nutshell, what you need to do is to calculate the number of workers prior to the 'actual' report doing anything...you can't implement from a formula inside the report.

HTH
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 07 Nov 2013 at 11:34am
sorry but your description is still alittle off to me. I am not 'seeing' how the distinctcount within a group apllies to all of your 'my field' records <>99.
Each row may be in a different worksetid...so do you really want to excldeu all <>99 becasue one grouping met the worker count condition?
 
If you mean myfield<>99 within each group group that is more doable.
So you can exlcude an entire group based on the group condition or you could suppress specific rows within each group based on your two conditions (group and row).
Or go lockwelle's direction of excluding the rows before you get them into the report.
 
Or perhaps you your myfield<>99 is a piece of meta data that is the smae across all of the rows for the group.
Again this would be a group select to remove it
 
DistinctCount ({MeterSessionOutput.WokerID},{WorkSet.WorkSetID}) >N
and
Minimum({MeterSessionOutput.MyField},{WorkSet.WorkSetID})<>99
 
IP IP Logged
Page  of 2 Next >>
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