Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Good morning... I am stumped!! Post Reply Post New Topic
Author Message
yerp458
Newbie
Newbie


Joined: 12 Apr 2012
Online Status: Offline
Posts: 3
Quote yerp458 Replybullet Topic: Good morning... I am stumped!!
     Posted: 12 Apr 2012 at 4:48am

Good morning... Here's what I'm trying to accomplish:

1) I have a table that contains a test_date and a test_value. I need to loop through the test_values and order them from maximum to minimum.
 
2) set the max_test_value.
 
3) find the 2nd_max_test_value... with the following qualifications:
 
     a) there must be 21 days or more between the date of the max_test_value and the 2nd_max_test_value.... otherwise the second value is not considered, and the next greatest value would be evaluated.
 
     b) the difference between the max_test_value and 2nd_max_test_value must be <= 10%... otherwise the second value is considered an outlier and the next (3rd_max) value would be considered.
 
4) calculate the average of max_test_value and 2nd_max_test_value (or 3rd_max, if warranted) and display it.
 
Any help you can provide will be much appreciated. Thank you!
 
 
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 12 Apr 2012 at 7:11am
create a group on the test value and order descending.
use shared variables in formulas to keep track of your values
dynamically suppress details that don't match what you are after.
 
If all that you want is the end result, put all the Display values in the group footer and suppress the header and details all together.
 
I know it is vague, but there is alot to do, and not much detail given...so it appears that you are looking for hints as to how to proceed.
 
At least that is what I would do.
IP IP Logged
yerp458
Newbie
Newbie


Joined: 12 Apr 2012
Online Status: Offline
Posts: 3
Quote yerp458 Replybullet Posted: 12 Apr 2012 at 8:31am
Thank you very much for the reply, and I apologize for not including more detail. I'll try to describe the problem more clearly.
 
My users are entering 3 lab values into a form along with the date that the labs were recorded. Those values are then recorded into our database when the user submits the form. The values are FEV1, FVC & FEF.
 
These values are then displayed in my crystal report in the details section, sorted by lab date. So the user will see the date of the lab, FEV1, FVC & FEF. The purpose of this report is to spot trends in the patients pulmonary function, so the nurses need to view the lab values sorted by the lab date.
 
For each of these columns of displayed values, I need to then run the calculations that are described below starting with the FEV1 column:
 
1) Review all of the values that are entered for FEV1 and select the Maximum Value.
 
2) Review the remaining values and select the 2nd highest FEV1 value. Before setting this value as the 2nd highest value, it has to meet the following two criteria:
       
      a) the difference between the date of the Maximum FEV1 & the 2nd Highest FEV1 value has to be >= 21 days
 
AND
 
      b) the difference in the actual value between the Maximum FEV1 and the 2nd Highest FEV1 value has to be <= 10%.
 
If either of these criteria are not met, we would want to locate the next (3rd) highest FEV1 value entered by my users and evaluate it as we've done above in steps 2a & 2b.
 
3) Once we have the Max & 2nd Max values set, we need to get an average of the two.
 
4) This average will then be used in a simple division formula whose result will be displayed in the column adjacent to the FEV1 column. The formula will divide the actual FEV1 value (entered by the user) by the average that we've just calculated. This should be displayed in the column adjacent to each FEV1 value that is entered. So for each row, we should see the FEV1 value and the calculated value FEV1 % Predicted.
 
This same process will need to be followed for the other two columns mentioned above (FVC & FEF).
 
So the fields that are displayed in the details section are: Test Date, FEV1, FEV1 % Predicted, FVC, FVC % Predicted, FEF, FEF % Predicted.
 
The FEV1, FVC and FEF fields are provided by the users. The FEV1% Predicted, FVC % Predicted and FEF % Predicted fields are then calculated and presented for each of the rows in the details section.
 
I hope this is helpful. If there's a way for me to post a pdf of the report as it now sits... it might be helpful to actually see the layout.
 
Again... thank you very much for any help that you can provide. It's very much appreciated.
 
IP IP Logged
yggdrasil
Senior Member
Senior Member
Avatar

Joined: 19 Jun 2007
Location: United Kingdom
Online Status: Offline
Posts: 150
Quote yggdrasil Replybullet Posted: 17 Apr 2012 at 3:55am
I can see why you are stumpedSmile 
It reminds me of a report I had to do for school attainment determining the gap between the bottom 20% of children in a school and the median score.
I'm sure someone will suggest you should use stored procedures, but if, like me, this is not an option, here's a suggestion.
Assuming you are grouping by patient, firstly I'd use a subreport for each of the 3 tests, on 3 successive detail lines. That way you can sort them by value, and use formulae to 'label' the detail line of the maximum, and the next one down that meets your criteria. Then you can calculate the average of the two selected with the right label.  The values you want to see in the main report can be passed in and out by shared variables, and lined up in the group footer of the patient group.  You can then suppress the three subreports so they don't show.  Not the most efficient way, but it should work.
IP IP Logged
yerp458
Newbie
Newbie


Joined: 12 Apr 2012
Online Status: Offline
Posts: 3
Quote yerp458 Replybullet Posted: 17 Apr 2012 at 4:38am
Thank you so much for taking the time to look at this one... I'll definitely give this a try!  Smile
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