Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: How do I filter based on the top one Post Reply Post New Topic
Author Message
proone
Newbie
Newbie
Avatar

Joined: 06 May 2011
Location: United States
Online Status: Offline
Posts: 7
Quote proone Replybullet Topic: How do I filter based on the top one
     Posted: 01 Mar 2012 at 8:09am
This is my record selection formula:


{enc.enc_timestamp} in {?Date Range} and
{provider_mstr.description} in {?Provider} and
{enc.billable_ind} = "Y" and
{enc.clinical_ind} = "Y" and

({proc.cpt4_code_id} = "99201" or {proc.cpt4_code_id} = "99202" or {proc.cpt4_code_id} = "99203" or {proc.cpt4_code_id} = "99204" or {proc.cpt4_code_id} = "99205" or
{proc.cpt4_code_id} = "99211" or {proc.cpt4_code_id} = "99212" or {proc.cpt4_code_id} = "99213" or {proc.cpt4_code_id} = "99214" or {proc.cpt4_code_id} = "99215" or
{proc.cpt4_code_id} = "99241" or {proc.cpt4_code_id} = "99242" or {proc.cpt4_code_id} = "99243" or {proc.cpt4_code_id} = "99244" or {proc.cpt4_code_id} = "99245")

and
(DateDiff("h",{enc.enc_timestamp},{proc.create_timestamp}) > 23)

I am having problems with the last bit after the last 'and'. How do I select top 1 proc.create_timestamp where cpt4_code_id = 'any of the above' sorted by create_timestamp ascending?

Can I use SQL in Crytsal formula editor? Thank you in advance!
IP IP Logged
rkrowland
Senior Member
Senior Member
Avatar

Joined: 20 Dec 2011
Location: England
Online Status: Offline
Posts: 259
Quote rkrowland Replybullet Posted: 01 Mar 2012 at 11:11pm
First simplify the above;
 
stringvar array codes:= ["99201", "99202", "99203", "99204", "99205",
"99211", "99212", "99213", "99214", "99215", "99241", "99242",
"99243", "99244", "99245"];
 
{enc.enc_timestamp} in {?Date Range}
and
{provider_mstr.description} in {?Provider}
and
{enc.billable_ind} = "Y"
and
{enc.clinical_ind} = "Y"
and
{proc.cpt4_code_id} in codes
 
To select the top 1 you'll need to group on a field, I'm not sure what fields you have available or what you want to report on so that decision is up to you.
 
Once you have a group you need to create a summary on the field you want to display the top one of, ie {proc.create_timestamp}.
 
Now goto the Group Sort Expert, select the group you want to filter, select Top N, where N is 1 based on the above summary.
 
Regards,
Ryan.



Edited by rkrowland - 01 Mar 2012 at 11:12pm
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