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

Two Different Fields - one total

Status
Not open for further replies.

Crystalguru

Technical User
Oct 4, 2001
303
US
Hello,

I am using CR 8.5, MS SQL 2000 and a stored procedure for this report.

In the stored procedure, one field captures the Height and Weight of a person - call it typecode. Another field captures the numeric value of the height or weight - call this HTWT.

Here is how my data looks like from the stored procedure:
Person ID CodeNum TypeCode HTWT
100 1 Height 65
100 2 Weight 82.89
101 1 Height 60
101 2 Weight 75.45

My report is grouped:
GH1 = Person ID
GH2 = CodeNum
GH3 = Typecode, HTWT

My report looks:
John Smith
Height: 65
Weight: 82.89

My problem is - I need to use the height and weights to form a calculation.

I tried a running total, here's my formula minus the reset and display formula-
whileprintingrecords;
numbervar nHeight;
numbervar nWeight;
numbervar BSA;

nHeight := if {codenum} = 1 then {HTWT}
nWeight := if {codenum} = 2 then {HTWT}

BSA := (nHeight ^ 0.725)*(nWeight^0.432)

I'm not getting the height and weight to calculate. I only get the weight value.
Any ideas?
 
Try this
In GH 2
whileprintingrecords;
shared numbervar nHeight;
shared numbervar nWeight;

nHeight := if {codenum} = 1 then {HTWT}
nWeight := if {codenum} = 2 then {HTWT}

In GF 1
whileprintingrecords;
shared numbervar nHeight;
shared numbervar nWeight;

{nHeight ^ 0.725)*(nWeight^0.432)

numbervar BSA;


-LW
 
Try:

whileprintingrecords;
numbervar nHeight;
numbervar nWeight;
numbervar BSA;

if {table.codenum} = 1 then
nHeight := {table.htwt} else
nHeight := nHeight;
if {table.codenum} = 3 then
nWeight := {table.htwt} else
nWeight := nWeight;

BSA := (nHeight ^ 0.725)*(nWeight^0.432);

Place the display formula below in the group #1 footer:

whileprintingrecords;
numbervar BSA;

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top