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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with variable to pull first value from detail line into group footer.

Status
Not open for further replies.

torolimon

Technical User
Oct 30, 2008
20
0
0
US
Group 1 Header Department Admit Time
Detail line 1 Dept 1 8:00
Detail line 2 Dept 2 9:00
Detail line 3 Dept 3 10:00
Group 1 Footer Dept 1 (this is the value I want to see but if a do a Max or Min summary I keep getting either Dept 2 or Dept 3 because their actual names are considered the Max or Min by Crystal)
I need to pull this first value into the Group 1 footer because I have calculated other fields in the report using variables which are displayed in the Group 1 footer.
 
The simplest approach would be to reverse the sort order and place the Department Name field in the GF.

Assuming this isn't an option for some reason, , I would create a Running Total (call it {#Count}) to count detail lines, reset on change of Group1. Then in the detail section, place the following formula:

Code:
WhilePrintingRecords;
Global StringVar FirstDept;
If      {#Count} = 1
Then    FirstDept := {Table.Department}

Then in the GF section, place the following Formula:

Code:
WhilePrintingRecords;
Global StringVar FirstDept;

Hope it helps.

Cheers
Pete.
 
Thank you that worked. I was doing the same thing but I was including an "else " " " on the end of it and it was messing it up. Thanks again.
 
I was looking to do the same thing with patients and the datetime that a certain intervention was documented on.

I moved the patient's account number and name to the group footer.
My running total looks like this:

Running Total Name: Count
Field to summarize: NurTimesDone.BaseID
Type of Summary: Count
Evaluate: Use a Formula which is {NurTimesDone.BaseID}="120096"
Reset: On change of field {NurTimesDone.BaseID}

This is giving me what I want to see...
If the patient has 120096 documented on several times, the count increases each time. if another intervention is documented on, #Count = 0

Now what I want to see is the first datetime next to the patient in the group footer (which would be where #Count=1).

When I use the code above in the detail section I get an error that says "The formula can not be evaluated at the time specified"

Any ideas why this would be?
 
I stay away from using the running totals because they don't work when trying to get counts on reports with conditionally suppressed records.
 
Bethany, your best option may be shared variables. Something like:

shared numbervar icnt ;
shared timevar itime;

if {table.baseid} = '120096'
then
(icnt := icnt + 1 ; if icnt = 1 then itime := {table.timefield} else itime := itime)

You will also need to put a reset formula for the variables in the suppressed report header and group footer b (I've never used a time variable so I'm not exactly sure what the reset value would be).
 
why shared variables?

_____________________________________
Crystal Reports 2011 and XI
Intersystems Cache 2012 ODBC connection

 
The only time I've used shared variables is when I'm trying to pass a variable from a subreport to a main report.
 
Bethany,

You could just create a formula like this:

//{@count120096}:
if {NurTimesDone.BaseID}="120096" then 1

Place this in the detail section and insert a sum on it at the patient group level.

Similarly, you can create a formula like this:

if {NurTimesDone.BaseID}="120096" then
{table.datetime} else
datetime(9999,9,9,0,0,0)

Then insert a minimum on this formula. You can then place the resulting summaries either in the group header or the group footer for patient.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top