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!

Urgt! values stored in a formula appear zeros when placed group footer 1

Status
Not open for further replies.

yehong

Programmer
Sep 22, 2003
291
US
Hi, My report has two groups:
group no. 1: Departments
group no. 2: Gender
I have two formulas (manula running totals) which I have placed in the group footer section of group no.2, ie Gender group
//@AvgF
//calculates Average Salary for all Females
if {Table1.Gender}='F' then
sum({Table1.Salary},{Table1.Gender})/count({Table1.Salary},{Table1.Gender})

//AvgM
//calculates Average Salary for all Males
if {Table1.Gender}='M' then
sum({Table1.Salary},{Table1.Gender})/count({Table1.Salary},{Table1.Gender})

Now I have a third formula
//@TotalAvg
@AvgM/@AvgF

which I am placing in the group footer section of group no.1, ie Departements. This formula is returning zero values for each Department. What am I doing wrong here?
Please advise.

Thanks,
 
You must assign the result of your running total calc to a variable.
More like this:


shared numbervar myvar1;
if {Table1.Gender}='F' then
myvar1:=sum({Table1.Salary},{Table1.Gender})/count({Table1.Salary},{Table1.Gender})

(so something similar for other formula)

and the footer would be more like:
shared numbervar myvar1;
shared numbervar myvar2;
myvar1/myvar2
 
For the summaries for the gender group, just insert an average on {table1.salary}.

For the ratio of salaries of males to salaries of females, you could use two running totals. Select {table.salary}, average, evaluate based on a formula:

{table1.gender} = "M" //for the {#MaleSalRT}

{table1.gender} = "F" //for the {#FemaleSalRT}

Reset on change of Group (Department).

Then create a formula {@ratio} for the Group (Department) Footer:

{#MaleSalRT}/{#FemaleSalRT}

-LB

 
Lbass, I had tried running total first and they were becoming zero when I was placinga formula in the footer of Departments.

Then I tried pelajhia's solution and it is working fine.


Thanks to both responses.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top