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

How can I divide SUM of fields?

Status
Not open for further replies.

chrislarkin

Programmer
Jun 5, 2001
31
0
0
Hi,

Using Crystal Reports 9.0, I have fields which are SUMs added with the SUM button, and I need to divide one sum by another one ... is there anyway to do this in a formula?

??
 
Sure,
1. Create a formula. @Divide
2. In the Formula Editor, expand the ReportFields section of the Fields list
3. You should see both of your summaries on this list. They'll be prefaced with the sigma symbol, indicting that they're summaries.
4. Write your formula, being careful to check the denominator for a 0 value.
eg 1 if you're working with subtotals
Code:
If Sum({field1},{Your GroupField}) <> 0 
then Sum({field2},{Your GroupField})/Sum({field1},{Your GroupField})

eg 2 if you're working with Grand Totals
Code:
If Sum({field1}) <> 0 
then Sum({field2})/Sum({field1})


Bob Suruncle
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top