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!

Variable Sum Not Correct In Header 1

Status
Not open for further replies.

reidtw

MIS
Feb 10, 2004
74
0
0
GB
Hi all

I'm using CR8 against a SQL2K db.

My prob is that a summed variable I have in the group footer is not behaving the same way in the header. I need to be able to suppress the group header and footer based on a number formula using a particular summed variable.

Here are some details: -

NO subreports!

The data is grouped by a fund code and then security id (with additional grouping that was provided in a previous post of mine -> thread767-921002 ).

The variables are: -

//@DealMth1
Whileprintingrecords;
NumberVar DealMth1;
DealMth1:=
if {Trade.Type} = "B" and
month(minimum({?DateRange})) = month({Trade.Date}) then
Month({Trade.Date})

//@DealMthSum1
whileprintingrecords;
NumberVar DealMth1;
NumberVar Sum1;
Sum1:= Sum1 + DealMth1;

//@DealMth2
Whileprintingrecords;
NumberVar DealMth2;
DealMth2:=
if {Trade.Type} = "S" and
month(minimum({?DateRange})) = month({Trade.Date}) then
Month({Trade.Date})

//@DealMthSum2
whileprintingrecords;
NumberVar DealMth;
NumberVar Sum2;
Sum1:= Sum2 + DealMth2;

//@DealMthSum3
whileprintingrecords;
NumberVar Sum3;
Sum3:= NumberVar Sum1 + NumberVar Sum2;

All three sums have been reset in grp2 (Security Id).

Now, when I drop @DealMthSum3 into the grp2 footer it is fine, say summing to 9, but in t'header it is at 0.

How do I get it to read the values the same way?

Cheers
T


 
First of all, you don't need variables here. If you remove the variables and the "Whileprintingrecords", you will be able to insert summaries on your formulas, and the results will be the same in the group headers as in the footers.

Secondly, do you realize that you are trying to add monthnumbers?

//{@DealMth1}:
if {Trade.Type} = "B" and
month(minimum({?DateRange})) = month({Trade.Date}) then
Month({Trade.Date})

The above formula will return a 2 if the month is February. If you add this across records, you would be adding a 2 and if the next month was April, a 4, for a total of 6. Do you really mean to do this? or do you mean to count records that meet your criteria? If so, replace the final "month({trade.date}) with a 1.

-LB
 
Hi lbass,

Yes, I know the result is the month number. After the totals are available, I wanted to suppress deals from the header and footer with a formula such as: -

if Remainder({@DealMthSum3}, month(minimum({?DateRange})) ) = 0 Then True Else False

The reason for this is that a buy and sell deal for the same security should not be reported if both are in the first month of the reporting period; the reporting period is over two months.

I was thinking this could only be achieved with unique variables rather than just summaries. If you are still of the opinion I have still complicated this please advise.

Apologies for omitting the above from my original post.

T
 
Still no need for variables. Each formula should look something like this:

//@DealMth1:
if {Trade.Type} = "B" and
month(minimum({?DateRange})) = month({Trade.Date}) then
Month({Trade.Date})

Then you can create a formula {@all} that adds them together:

sum({@DealMth1},{table.securityID})+
sum({@DealMth2},{table.securityID})+
sum({@DealMth3},{table.securityID})

Then use that formula in your suppression formula:

Remainder({@all}, month(minimum({?DateRange})) ) = 0

-LB
 
Thanks lbass, worked a treat, must stop using variables and go back to basics!

Thanks again
T
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top