Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Counting specific records

Status
Not open for further replies.

MadCatmk2

Programmer
Oct 3, 2003
145
GB
Hi all

I'm really hoping someone could shed some light on the problem i'm having with a crystal report.

I have a report that defines whether a patient is a high dependancy or a low dependancy case. The report is initially grouped on a locality field(5 Localities), then on a date of visit (weekly grouping) and finally on a patient number. It shows up the patients visited in each week for each locality. within the patient grouping i have the visit dates and the duration of visits. i have a count of the visits and the sum of the durations. A high dependancy patient has more than 6 visits in a week or over 180 minutes duration a week.

Here's where the problem starts. i have a two formulas that check each patient for the duration and the visit count, 1 if the patient is high and 0 if they are low dependancy. A final formula field (@highdepcount) checks that either of the previous two formulas are one and then assigns 1 for high and 0 for low dependancy. I'd like to be able to perform a sum on this last formula field to get a count for those patients who are a high dependancy. Unfortunately if i try to sum it, the error "This field cannot be summarized" appears.

Does anyone know of any better ways to do this or how i could get the sum of @highdepcount

Hope this makes sense

Thanks in advance
 
In Crystal 8.5, you can do Running Totals and this should take care of it. Running totals can include a formula.

The thing about summary totals is that they get calculated from the database fields, and so can be put in the group header. They can't cope with data derived from more than one record, since this is only known at a later stage in the processing cycle.

If you have an older version of Crystal and lack running totals, you could probably do it by adding variables. A keyword search might give you some useful examples.

Madawc Williams
East Anglia, Great Britain
 
Thanks for the quick reply. I have a few queries regarding the running total. Would i be able to run the total on the @highdepcount formula which stores 1 for high and 0 for low, or would i have to run it on both @ContactCheck and DurationCheck which are the two formulas which check if either of these class the patient as high dependancy.

I'm also not sure how to go about starting the Running total. From what i can see i will still be summarising the @highdepcount field which doesn't appear in the available running total fields. I think i may have mis understood your reply.

Could you possibly elaborate on the running total part?

Thanks very much for your reply
 
You may have to re-do the test formulas within the formula section of the running total. It has to pick on a database field to do the counting on, but you then control whether it counts or not.



Madawc Williams
East Anglia, Great Britain
 
Ok

I apologise if this sounds stupid but here's what i think is required from what you've said.

i'm using crystal 9.

Summarised field := Patient Number
Type of Summary := Count

Its the evaluation part that puzzles me. I think i need to evaluate on a formula from what you have said. ContactCount and DurationSum are summaries in the patient Number grouping.

within the formula :=
ContactCount >= 6 (6 days) or DurationSum >=180 (minutes)

and i need to reset my count after each locality

Does this sound like the right idea, or do i need more in the formula?

Thanks and apologies for not being to quick this morning



 
I have another possible way of doing this but i have a question about that as well. I have set up two formulas, @inc and @incReply

@inc:

global numbervar counter;
whileprintingrecords;
if (Count ({1_ALL_CONTACTS_FOR_SPECIFIED_PERIOD.DATE_OF_VISIT}, {1_ALL_CONTACTS_FOR_SPECIFIED_PERIOD.PATIENT_NO}) >= 6 or
Sum ({1_ALL_CONTACTS_FOR_SPECIFIED_PERIOD.DURATION}, {1_ALL_CONTACTS_FOR_SPECIFIED_PERIOD.PATIENT_NO}) >= 180)
then counter:=counter+1;

@incReply:

global numbervar counter;
evaluateafter({@inc});
counter;

Inc is placed in the patient number group header and increply is in the locality footer. The only problem i have with this working is that it doesn't reset. How would i reset the counter each time a new locality is changed to.

Thanks
 
I have it sorted.

I used the method outlined in the last post, to reset all i had to do was to set a reset formula which was set to evaluate after the incReply formula and then initialise the counter variable to 0.

sorry about all the questions. Thank you for your help, it was much appreciated.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top