Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Selecting most recent values Post Reply Post New Topic
Author Message
valkyriex
Newbie
Newbie
Avatar

Joined: 03 Aug 2007
Location: United States
Online Status: Offline
Posts: 3
Quote valkyriex Replybullet Topic: Selecting most recent values
    Posted: 03 Aug 2007 at 8:36am
Hi,

I'm running a medical report where I need to find patients with BMI value = xx. However, it has to be the most recent BMI reading. That means, if a patient has a BMI reading of xx in March, but yy in June, then that patient should not be included in the report.

Does anyone know of a formula that can specify such criteria?
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 03 Aug 2007 at 1:50pm
Can you just specify the current month in the record selection formula?
BMI=xxx AND Month({date field}) = Month(CurrentDate)

Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
IP IP Logged
valkyriex
Newbie
Newbie
Avatar

Joined: 03 Aug 2007
Location: United States
Online Status: Offline
Posts: 3
Quote valkyriex Replybullet Posted: 03 Aug 2007 at 2:03pm
Now what if the most recent reading was not during this month but say 3 months ago?  
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 03 Aug 2007 at 2:14pm
This sounds like  a different question. You said that if they don't have a XX reading in June then they shouldn't be in the report. Now you want them in the report if they had it 3 months ago? Confused. Can you clarify what the question is?
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
IP IP Logged
valkyriex
Newbie
Newbie
Avatar

Joined: 03 Aug 2007
Location: United States
Online Status: Offline
Posts: 3
Quote valkyriex Replybullet Posted: 03 Aug 2007 at 2:45pm
Originally posted by BrianBischof

This sounds like  a different question. You said that if they don't have a XX reading in June then they shouldn't be in the report. Now you want them in the report if they had it 3 months ago? Confused. Can you clarify what the question is?


It shouldn't be included because yy is the most recent value, not xx.  It's not a matter of whether it's in June or not.  The most recent reading does not have to be in this current month.  The most recent reading could be this month, last month, or 3 months ago.  Let's say today is August, if the latest BMI reading of a patient was from February and the value is XX, then I would need that patient in the report.

If I use the formula Month{CurrentDate}, doesn't that mean the query will only look for values recorded this month (August)?

IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 03 Aug 2007 at 2:50pm
Ok. I see what you mean now. You want to see if the max(date) has a value of XX.  You can only do it with a Command object. I answered this a while back:

http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=202
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
IP IP Logged
Post Reply Post New Topic
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



This page was generated in 0.016 seconds.