Joined: 08 Dec 2009
Location: New Zealand
Online Status: Offline
Posts: 3
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
Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
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'."
Joined: 08 Dec 2009
Location: New Zealand
Online Status: Offline
Posts: 3
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)
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