Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: cost in % of sales Post Reply Post New Topic
Author Message
ctm66
Newbie
Newbie


Joined: 08 Sep 2010
Location: Netherlands
Online Status: Offline
Posts: 3
Quote ctm66 Replybullet Topic: cost in % of sales
     Posted: 09 Sep 2010 at 1:09am
Hello,
 
I want to express all cost in a % of sales. I work in exact, have a group of aaccount that make a reportgroup, I have a report that is sortet on accountgroup, so all accounts of sales are grouped in a total of sales, all accounts of salary are grouped in a total of salary, the reports should look like :
 
Actual Budget
Sales 5.000 100% 6.000 100%
Purchase cost 2.000 40% 2.500 42%
Salary 1.000 20% 1.000 17%
Accomodation 750 15% 750 13%
Transport 500 10% 750 13%
Result   750     1.000  
 
How can I calculate every group total in a % of group total sales.
 
Thanks.
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 09 Sep 2010 at 3:16am
calculate the total of the sales by using SUM({table.field}, the grouping that works)
 
you could probably do that in the group header of where you are % and store it in a variable instead of constantly recalculating it...then it is {table.field} / total sales
 
 
IP IP Logged
ctm66
Newbie
Newbie


Joined: 08 Sep 2010
Location: Netherlands
Online Status: Offline
Posts: 3
Quote ctm66 Replybullet Posted: 09 Sep 2010 at 4:07am
Hi, thanks for your reply. But I think I was not clear, the report has a number of coscenters, and if I put the sum in a variabel, I think it goes wrong, or is it calculating for every costcenter the total of sales. The report looks like this :
 
Costcenter1
Actual Budget
Sales 5.000 100% 6.000 100%
Purchase cost 2.000 40% 2.500 42%
Salary 1.000 20% 1.000 17%
Accomodation 750 15% 750 13%
Transport 500 10% 750 13%
Result   750     1.000  
Costcenter2
Actual Budget
Sales 7.500 100% 8.000 100%
Purchase cost 2.500 33% 2.000 25%
Salary 1.600 21% 1.800 23%
Transport 250 3% 750 9%
Result   3.150     3.450  
 
etc.
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 09 Sep 2010 at 4:30am
depends, do you want to percentage each cost center separately or are they part of a larger grouping.  The variable, so to speak, is not the issue, it is what you want to percentage against (oh yeah, the variable needs to be shared or global so that its value is maintained the whole time)
IP IP Logged
ctm66
Newbie
Newbie


Joined: 08 Sep 2010
Location: Netherlands
Online Status: Offline
Posts: 3
Quote ctm66 Replybullet Posted: 09 Sep 2010 at 5:06am
Hi, i want to percentage each cost center seperately, the variable function is not working, or is it completely wrong, I use this :
 
WhileReadingRecords;
Global NumberVar x;
x := sum(if {AccountClasses.AccountClassCode}="20" then {@bedrag_maand})
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 09 Sep 2010 at 12:07pm
is the cost center represented by the {bedrag_maand}? if yes, your code should be like:
 x := sum({AccountClasses.AccountClassCode}, {@bedrag_maand})
 
do you only want a certain subset of the values in the cost center? if yes, then you can't accomplish what you want using SUM.  you will need to use a subreport to selectively calculate the total of the cost center.
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum