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

Group Total in a group Header

Status
Not open for further replies.

mikey1000

Programmer
Nov 21, 2005
2
US
I was hoping someone could help me out. I have a report that needs to take the sum of a group and use it to do a percentage calculation in a group header.

My code looks a little like this, unfortunately it is giving me the completely wrong result. Can anyone tell me what I may be doing wrong? Thanks


' Calculated in the Detail Section
WhileReadingRecords
global ValidCount as number
ValidCount = ValidCount + {Table1.Fieldname}
Formula = ""


' Get the average in the Group Header
WhilePrintingRecords
global ValidCount as number
global TotalValidCount as number
dim loResult as number
loResult = (ValidCount / TotalValidCount )
loResult = loResult * 100
Formula = loResult


' Total in the footer section
WhileReadingRecords
global TotalValidCount as number
Formula = TotalValidCount


 
Not sure why you are using variables. Create a formula:

sum({table.amt},{table.groupfield}) % sum({table.amt})

Place this in the group header and then click on the % sign in the toolbar. If you don't have record inflation, this should give you the correct percentage of the group sum compared to the report total.

-LB
 
Thanks for the response. What would I do though if I wanted to sum only part of the group based on a criteria?
 
Create a Formula
//@CustomSummary
If {YourTable.SomeField}="Some criteria"
then {YourTable.FieldYouWantToSum}
else 0

Use this formula field in your summary.
if Sum({table.amt}) <> 0 then
sum({@CustomSummary},{table.groupfield}) % sum({table.amt})


Bob Suruncle
 
You can use Bob's formula although I'm guessing you might want to be looking at the conditional amount for the group in relation to the total conditional amount, in which case the formula should be:

if Sum({@CustomSummary}) <> 0 then
sum({@CustomSummary},{table.groupfield}) % sum({@CustomSummary})

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top