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!

Calculations using subtotals 2

Status
Not open for further replies.

IanMac26

Programmer
Nov 16, 2007
20
NZ
I am using Crystal XI to do a Sales Analysis on 2 group levels. My groups are product and customer. At the detail level I have salesamount and costamount and have inserted summaries of both at product, customer and report levels. The subtotals show correctly, but when I calculate the profit margin (sales-cost)/cost*100 I get the correct answer at the product group level, but not at the customer level. This is most obvious when the customer has only bought one type of product, the subtotals are the same but the margins are different.
 
How are you calculating profit margin at customer group.

You should use a formula in group footer

@CustPF

(sum(sales, customer)-sum(cost, customer)/sum(cost, customer)*100

Ian
 
You probably should build in a check for cost being zero so you don't get a divided by zero error:

if sum({cost}, {customer}) = 0 then 0 else
(sum({sales}, {customer})-sum({cost}, {customer})%sum({cost}, {customer})

Also notice you do not need to multiply by 100 if you use the % symbol instead of the division /.

Software Sales, Training, Implementation and Support for Macola, eSynergy, and Crystal Reports

"What version of URGENT!!! are you using?
 
The 2 replies confirmed to me that I was doing the right thing. I re-entered the formulas(putting in the test for zero divisor and using the % operator), as I had done several times before posting. The formulas looked the same but now they work. :-D
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top