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

Displaying a field only in a group's last record

Status
Not open for further replies.

matpj

Technical User
Mar 28, 2001
687
GB
How can I do this?

After some VERY useful help in my previous thread, I need one final calculation in my report.

I have a subreport in my group header containing a field called "Actuals"
I have another field in my group header (main report) called "ETC"

In my group details I have a field called "Budget"

For only the LAST record of any group I need to have a field called "Variance" that has the following calculation (Budget - (Actuals + ETC))

how can I do this for the last record?
Or how can I suppress the field for all but the last record?

thanks in advance

 
What version of Crystal are you using?
If it is 9+ (and maybe 8)
create the variance field and put it where you want.
Format field
Click on the formula button

Type:

WhilePrintingRecords;
not onLastRecord

Does that work?
 
hi Katy,

I am using CR 9

I have created a field in which I calculate on the last record, but I cannot include the value from the subreport.

how can I use this value (as it is not in the list of Report Fields)?



 
Katy,

I got a bit confused with another thread then.

the formula I have in the field is:
whileprintingrecords;

{cr_hiport_project_etc_and_budget_v2_hiport_etc.Budget} - ({@Actual Days}+{cr_hiport_project_etc_and_budget_v2_hiport_etc.ETC})

I have tried putting "not OnLastRecord" in this but nothing happens.

I have also tried putting a formula in the suppress editor and this also doen't work.
I think its because my fields are in the group header rather than the detail.
Is there still a way to acheive it?
 
Which formula did you put in the suppress editor? I have used this and it worked for me, but I think what you are trying to do is a bit more complicated.
The way I understand it is that you have your formula in one field, and then you conditionally suppress that field (for all but the last record of the group)
Sorry I'm not being much help!
 
Katy,

thanks for your reply.
I think I have sorted it now.

however, if you are up to scratch on shared variables, maybe you could help me!

I have a field with the following formula:

WhilePrintingRecords;

Shared Numbervar SubPassedNum;

If OnLastRecord then

{@Budget hours}-(SubPassedNum + {cr_hiport_project_etc_and_budget_hiport_etc.ETC (days)})

Else 0;

This only seems to work for the last group returned. The previous groups last record is just '0', so it is looking at OnLastRecord as being the last record of the report.
how can I make it the last record of the group?
 
You could create a running total {#cntwingrp} using the running total editor: Select your group field, count, evaluate for each record, reset on change of group. Then adjust your formula to:

WhilePrintingRecords;
Shared Numbervar SubPassedNum;

If {#cntwingrp} = count({table.groupfield},{table.groupfield}) then
{@Budget hours}-(SubPassedNum + {cr_hiport_project_etc_and_budget_hiport_etc.ETC (days)})
Else 0;

-LB
 
what does this bit do:
count({table.groupfield},{table.groupfield})

 
Good Thinking LB

Mat

count({table.groupfield},{table.groupfield})

is a count of a field in your details section, insert this summary at group level.

Gary Parker
MIS Data Analyst
Manchester, England
 
I'm trying to give you a star lbass, but its not working..

right, that worked perfectly.
I showed the report to my manager, and he also wants me to generate the report twice.
once with the above formula, and once showing this figure but for the FIRST record in each group.

I'm trying to work out a way of doing the other way.

I have created a FirstReset boolean that I am setting to True in the group header.


Then i'm creating a formula field "FirstRecord"
containing:
WhilePrintingRecords;
Shared Numbervar SubPassedNum;
BooleanVar firstreset;

If firstreset then
{@Budget hours}-(SubPassedNum + {cr_hiport_project_etc_and_budget_hiport_etc.ETC (days)})
Else 0;

firstreset :=False;


but thats as far as I get.
where am I going wrong, cos it doesn't work!!
 
Try using the running total from the last solution but change your formula to

WhilePrintingRecords;
Shared Numbervar SubPassedNum;

If {#cntwingrp} = 1 then
{@Budget hours}-(SubPassedNum + {cr_hiport_project_etc_and_budget_hiport_etc.ETC (days)})
Else 0;


Gary Parker
MIS Data Analyst
Manchester, England
 
Thanks Gary,
it works well!

as you are probably all aware I am very new to Crystal Reports!
I'm slowly learning some valuable tricks thanks to you guys!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top