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()?

Status
Not open for further replies.

mission2java

Programmer
Jul 3, 2001
129
US
I have a report printing hours for employees of indirect hours and direct hours. I would like a sum for each..NOT a total sum..but a sum for all indirect per employee and all direct hours per employee.

I think i have the correct footer information but what is the expression I use to get the sum?

Jon
 
Hi Jon, I'm guessing that your data is something like this?

Hours Table
Employee Name Hours
Jon Smith 2
Jon Smith 3
Jane Doe 8
Jane Doe 4
etc and linked to some sort of employee table:

Employee Table Indir/Dir
Jon Smith Indir
Jane Doe Dir
etc

If so, you could do two separate formulas:

If {EmployeeTable.Indir/Dir} = Indir
Then
Sum({HoursTable.Hours},{GroupEmployee}) (I would assume you have a grouping level by employee in the report?

And the second formula:
If {EmployeeTable.Indir/Dir} = Dir
Then
Sum({HoursTable.Hours},{GroupEmployee})

Then you could drop the two fields where they belong on the report. You didn't give a lot of information so I'm making assumptions. If this isn't what you need, maybe you could expound a little. :)
 
I think you would have to use a variation on DianeMarie's formulas:

{@Indirect} - place in the details section:

If {EmployeeTable.Indir/Dir} = "Indirect"
Then {HoursTable.Hours}

For {@Direct}, just subsitute "Direct" and then insert summaries on these at the group and/or report level.

A conditional clause has to be evaluated at the level in which it occurs, i.e., the "if {employeetable.indir/dir} = "indirect" if placed in the group footer would always evaluate to the default (the implied 0), because the condition does not occur at the group level, but at the detail level.

-LB
 
Hmm this all seems strange...
cant I just sum the fields? It seems so tedious with all this code...Im not familiar with where I put the code...

Can someone point me out to the right places...
my data looks like this:

Jon H 5.4 Indirect
Jon H 4 Direct

Total 5.4 Indirect
Total 4 Direct

Joe B 3 Direct

Joe B 10 Indirect

Total Direct: 3
Total Indirect: 10

Except minus the totals...
I need to add all direct hours with one another and all indirect hours with one another and display.
Where do I look to put all that code?
 
Go to the field explorer->formula field and click on the new icon in the tool bar of the field explorer and a window will open where you name the formula. Once named, the formula area will open up and you can write the formula in there.

You could copy the formula above and just substitute your own table.field name, something like {employee.hourstype} and the corresponding result, like "indirect".

It won't be a lot of work for you--you only need two formulas. After you've placed them in the details section, you just need to right click on each of them and choose "summary" and choose "insert summary fields for all groups" and if you wish "insert grand total field."

After inserting the summaries, you can either delete the formulas from the details section or suppress them by right clicking on them, format field->suppress.

-LB
 
Sorry for being stupid again...
I still dont understand what you mean...

You have:
{@Indirect} - place in the details section:

If {EmployeeTable.Indir/Dir} = "Indirect"
Then {HoursTable.Hours}

But what is Indir/Dir? Where is there a sum in this???

You said Then {HoursTabl.Hours} but what does that do?

I just need to accumulate these hours...

Jon
 
See the problem is the person who wrote this did not specify a field for indirect or direct.
So i had to program it like this:

if {dbo_TBLLABOR.WORKORDERNUMBER} startswith "C" then
"Direct" else
"Indirect"

Now on my report I have this field named Group#4Name.

So now i need to sum the hours for direct and indirect...

can anyone help since i provided that initial if?
Isnt there a sum function? I HATE CRYSTAL!!! Access reporting is so much easier!

Jon
 
I may have sometihng how do i test for NOT

if {dbo_TBLLABOR.WORKORDERNUMBER} NOT startswith "C" then {TBLLHOURS.HOURS}

I want to say if the workordernumber DOES NOT start with C...

Jon
 
I think we (I) really got off track here. If you have grouped on employee and grouped on your formula:

if {dbo_TBLLABOR.WORKORDERNUMBER} startswith "C" then
"Direct" else
"Indirect"

Then your report already looks something like this:

John Doe
Direct (header)
date1 field1 field2 hours
date2 field1 field2 hours
Direct (footer)
Indirect (header)
date1 field1 field2 hours
date2 field1 field2 hours
Indirect (footer)

All you have to do is select the hours field, right click on it and choose "insert summary" and select "sum" and "insert summaries for each group."

Sorry for making it appear more complicated than it really was.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top