Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: select records depending on distinct field value Post Reply Post New Topic
Author Message
noobee
Newbie
Newbie
Avatar

Joined: 08 Dec 2009
Location: New Zealand
Online Status: Offline
Posts: 3
Quote noobee Replybullet Topic: select records depending on distinct field value
     Posted: 08 Dec 2009 at 12:48pm
Hi,

I'm relatively new to crystal and have hit a bit of a ceiling so hope you help.

I have a number of laboratory records and these records have one of 6 status's, ranging from unreceived "U" (for a new record) through to reviewed "V" (equivalent of closed). I am trying to create a report that pulls back different subsets of these lab records depending on the record status, at the time the report is triggered. i.e. if the record status is reviewed, "V", then show me only the last week of "V" records however if the status is "U", "I","P","C" (one of the status's that relates to currently open records) then show all records. I also want to exclude all records with a status of "X" (cancelled)

The primary grouping in my report is lab record status, I also have subgroupings.

I am trying to write a formula using an if/then clause but am a bit stuck


if {PROJECT.STATUS} = "V" then {PROJECT.DATE_REVIEWED} in LastFullWeek
and if {PROJECT.STATUS} = "X" then ##(cancelled status, I'm not sure what to put here to exclude these)##
else {PROJECT.STATUS} (##(I want to show records with all other status's)##


btw, if there is a simpler way of doing this without formulas I'm all ears

Any assistance much appreciated       

Edited by noobee - 08 Dec 2009 at 12:51pm
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 08 Dec 2009 at 1:30pm
I think this will work in your select statement:
 
(
{PROJECT.STATUS} = "V" and {PROJECT.DATE_REVIEWED} in LastFullWeek
)
 or
{PROJECT.STATUS} in ["U", "I","P","C"]
 
 
Although your description leads me to believe you really want the last 7 days not the previous week:
 
(
{PROJECT.STATUS} = "V" and {PROJECT.DATE_REVIEWED} in Last7Days
)
 or
{PROJECT.STATUS} in ["U", "I","P","C"]


Edited by DBlank - 08 Dec 2009 at 1:35pm
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 08 Dec 2009 at 1:52pm

You can't actually use an If statement in a record selection formula.  However, there is a way to do this - each "piece" of the selection criteria has to evaluate to true or false and you have to group things together with parentheses.  So, it will look something like this:

(({PROJECT.STATUS} = "V" and {PROJECT.DATE_REVIEWED) in LastFullWeek) 
or
({PROJECT.STATUS} <> "X" and {PROJECT.STATUS} <> "V"))

The first part translates to "If the project status = 'V' then just select the ones reviewed in the last week" and the second part translates to "Give me everything else with a project status that's not 'X' or 'V'."
 
-Dell
IP IP Logged
noobee
Newbie
Newbie
Avatar

Joined: 08 Dec 2009
Location: New Zealand
Online Status: Offline
Posts: 3
Quote noobee Replybullet Posted: 08 Dec 2009 at 2:23pm
worked like a charm, many thanks.

is there a way to seperate the status "V" from the other status's so that this will appear first (at the moment the status's look to be sorting alphabetically. I'm not having much joy with the sorting expert)
IP IP Logged
noobee
Newbie
Newbie
Avatar

Joined: 08 Dec 2009
Location: New Zealand
Online Status: Offline
Posts: 3
Quote noobee Replybullet Posted: 08 Dec 2009 at 2:34pm
sorry, have just figured it out.
thanks again
IP IP Logged
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