views:

418

answers:

3

I have a crystal report that is connecting to a database. The datatable from which this information is coming from is rather large and I need to know how to filter information.

I have a field in my report that needs a list of requirements. The datatable i'm pulling from has all these extraneous requirements for other departments that I do not need.
For example:

I only need to see NY IT Office service information. The column in my datatable shows everything such as kitchen services, laundry, parking, IT dept info, and finally Office Services. Sometimes the entries that I pull from involve all of these departments--however I ONLY care about my dept.
How then can i place a filter on my field to show ONLY what i need to see for my specific dept and to not display the other info? I tried using the Select Editor...but it seems if I was to tell it to not display Kitchen services for example, it would not show the entire entry (even if my dept. was involved).

I don't know if this is clear or not--but some help using this damned Formula editor would be much appreciated.

A: 

You could access the data through a stored procedure, building the filter logic into it.

Carlton Jenke
If he has only read-only acces to the database, then he could only access this through a stored procedure that already exists.
David Stratton
his comment about access was added after my answer
Carlton Jenke
+1  A: 
OMG Ponies
i'm not 100% sure what you mean but the "weird looking button" on the right of the Suppression option. I'm not seeing this in my Select Expert---are you using Crystal Reports 10.0?
+1  A: 

If you have any version of Crystal after 8.5, you can use pretty much any SQL you want as a Command source for a report, removing the necessity of creating any DB objects.

What is stored in this requirement field? It sounds a bit like you have multiple values per row.

EDIT : Ok, as the field is indeed multiple values, there are various things you can try.

1) If 'Office Services' is definitely unique (ie, there's no entry for 'Main Office Services' as well as 'Office Services', for example), then you can use a simple LIKE in your record selection formula :

{tblData.MultipleValueField} LIKE "*Office Services*"

2) If you can't make that assumption, then you can use an array to split the values out and then test for the presence of just 'Office Services' :

"Office Services" In Split({tblData.MultipleValueField}, ",")

Option 1 will probably run quicker, as the filter will be done server-side and fewer records will be sent over the network. Option 2 will involve Crystal doing the filtering and more network traffic. I hope one of these meets your requirements.

CodeByMoonlight
I am using Crystal Reports 10.0 for this and I tried to use their SQL expression editor...but it seems that they have their own weird syntax for it which i'm not able to pick up on. The requirements column in the data table is a concatenated field with comma delimiters. I just want to make it so that I can extract what I need and suppress showing the rest of the information.
SQL Expression Formulas are a little different, and I've personally never found them very useful. See my edit relating to the Record Selection Formula.
CodeByMoonlight