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!

Sum of a field

Status
Not open for further replies.

katididdy

Technical User
Joined
Mar 13, 2006
Messages
70
Location
US
How can I sum a field, when the sum () function states that the field cannot be summarized? The field is the amount of the pay out for each employee.
 
It sounds like you are trying to summarize a formula that contains some element that makes it ineligible for an inserted summary or that you are trying to summarize a summary--so what is the formula or summary?

-LB
 
The formula is

if {@pay amount total} < 3
then 0
else
{@pay amount total} * {F060116_Employee_Master.YAPHRT_Hourly_Rate};

The function displays the amount that person should be paid, and I need to sum it at the end of the report. Do you have ideas that may help me?
 
You should always show what is in any nested formulas, also, i.e. {@pay amount total}.

There might be a simpler method (if we knew the contents of all formulas), but here is a general method that will work. Create two formulas:

//{@accum} to be placed in the employee group header or footer:
whileprintingrecords;
numbervar empltot := empltot + {@yourformula};

//{@displ} to be placed in the report footer:
whileprintingrecords;
numbervar empltot;

If your formula result is a currency, not a number, change "numbervar" to "currencyvar" in the above formulas.

-LB
 
I was able to get the formulas written as follows:

//@accum
whileprintingrecords;

currencyvar empltot := empltot + {@Wage amount to pay};

//@disptot
whileprintingrecords;

currencyvar empltot;

When I calculate @wage amount to pay using a calculator, I get $65.323.67. When the report processes, the amount I get is $417,493.83. A huge difference! @accum is in gh2 and @disptot is in the report footer. What mistake am I making? If I put @accum is gh2 the report total is $9,057.71.
 
Okay, now we definitely need to see the content of your nested formulas, as it sounds like you might be using the previous or next function, not just a sum or other summary. Also please indicate what section {@Wage amount to pay} is placed in--where it calculates correctly. Please note that you referenced the same section for the two different totals in your last two sentences.

-LB
 
I see the mistake I put in my response: {@Wage amount to pay} is in gf2. The only way I get it to come out correctly is to print out the report, and then by hand add it. I did that 3 times to make sure I wasn't making a mistake on my calculator.

{@wage amount to pay} is in gf2, and the formula is:
if {@pay amount total} < 3
then 0
else
{@pay amount total} * {F060116_Employee_Master.YAPHRT_Hourly_Rate};


Hourly rate is not in the report, it is being pulled from the database. {@pay amount total) is in gf2 as well, and it's formula is:

if year ({F060116_Employee_Master.YADSI_Date_of_Original_Employment}) = 2006
then 0
else
{@Vaca fig1} + {@Vaca fig2};

{@vac fig1} and {2} are not in the report, just a function that is called. Date of original employment is being pulled from the database.

with a slight variation on the comparison, the formula for {@vaca fig1} is:

if {@Hours Used} >= {@Min Should Have Used}
then {@hours earned} - {@Hours Used}

and all of these are in gf2.

I hope that helps you! I, too, am still working on it.
 
Did you think that LB would know what's in these formulas:

{@Hours Used} >= {@Min Should Have Used}
then {@hours earned} - {@Hours Used}

The point of LBs post was that we need to know what you are referencing, nd any embedded formulas are part of that...

Anyway, you'll probably need to manually do the sums within formulas, but I would suggest posting the intent as this level of nesting might be avoidable.

-k
 
If your formula {@Wage amount to pay} is displaying the correct amount in GF2, then I think the formulas I mentioned should add the amounts correctly, i.e., they should total every instance of your formula in GF2.

-LB

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top