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!

cumulative percentages

Status
Not open for further replies.

jehanzebn

Programmer
May 28, 2001
244
Morning all,

I would like to know if I can use cumulative percentage in my crosstab. I am currently using normal percentage on Order numbers using Distinct Count but now I would like to see cumulative percentage instead of normal one.

Any ideas how to go about this?

Regards

Jehanzeb
 
Sorry I missed the example: here it is

For example:

Current Situation

Day 1 - 23 Jobs - 40.35%
Day 2 - 23 Jobs - 40.35%
Day 3 - 5 Jobs - 8.77%
Day 4 - 6 Jobs - 10.53%

Total = 57 Jobs - 100%

Now if you look at this, the percentage is not cumulative. What I need is a cumulative percentage, so it should look like

Day 1 - 23 Jobs - 40.35%
Day 2 - 23 Jobs - 80.70%
Day 3 - 5 Jobs - 89.47%
Day 4 - 6 Jobs - 100.00%

Total = 57 Jobs - 100%

as cumulative is something which is increasing by successive additions. So in this case the percentage is keep increasing.
 
Using variables, you could add the figures. Or you might do it with a running total plus a summary total, the result calculated in a formula field.

If you're not already familiar with Crystal's automated totals, see FAQ767-6524.

PS. It helps to give your Crystal version - 8, 8.5, 9, 10, 11 or whatever. Methods sometimes change between versions, and higher versions have extra options.


[yinyang] Madawc Williams (East Anglia, UK). Using Windows XP & Crystal 10 [yinyang]
 
Hello and thanks for the informative answer.

Sorry I didn't mentioned earlier I am using 2008 version of Crystal.

I am familiar with the running totals etc and have tried them however, it didn't work under Crosstab.

Code:
Local NUmbervar x:={Order_header.Order_no};
x:=x+{Order_header.Order_no};

This didn't work.

I am using Crosstab to calculate number of orders per day and then taking their percentage per order per day however, I need to add the percentage as day goes by.

For example:

Day 1 - 23 Jobs - 40.35%
Day 2 - 23 Jobs - 80.70%
Day 3 - 5 Jobs - 89.47%
Day 4 - 6 Jobs - 100.00%

Total = 57 Jobs - 100%

So each percentage is getting updated each day, adding each percentage value.

40.35+40.35=80.70

So the 2nd Day the percentage would be 80.70% instead of 40.35.

80.70+8.77= 89.47
So the 3rd Day the percentage would be 89.47% instead of 8.77%.

89.47+10.53 = 100
So the 4th day the percentage would be 100% instead of 10.53%.

Its adding up the percentage values as the day goes by.

How can I achieve this?

Regards

Jehanzeb
 
Please see the running total method (within field formatting formula areas) towards the end of this thread:
thread149-1482942 .

-LB
 
Ibass,

That is the superb link you have given me though I have few questions here.

I have tried it and now the total result is showing 200% and all the values in that column are as it is.

So now the records look like this

Day 1 - 23 Jobs - 40.35%
Day 2 - 23 Jobs - 40.35%
Day 3 - 5 Jobs - 8.77%
Day 4 - 6 Jobs - 10.53%

Total = 57 Jobs - 200%

I am sure I must have done something wrong.

Here what I did.

I selected both Column fields (percentage field and Total percentage field).

Clicked format ----> then Suppress and clicked on x+2
added the following formula
Code:
whileprintingrecords;
numbervar x := x + currentfieldvalue;
false
Then I clicked only on Total Percentage field and right clicked and clicked on Display String x+2
Code:
whileprintingrecords;
numbervar x;
totext(x,1)+"%"
Then I clicked on border--->background--> and added this formula

Code:
whileprintingrecords;
numbervar x := 0;
defaultattribute

Now the total is showing 200% as I said however that is not what I was expecting.

It should count each column record and add the next one and show the total of two column records in 2nd column and so on.

am I making sense here?

Regards

Jehanzeb
 
Ibass!!!

You are the MAN!!!

It is working

Sorry I made a mistake there.

Instead of displaying the total on the columns I did it on the total field.

Other way round! doh!!

haha

Thanks very much

Regards

Jehanzeb
 
One thing I didnt understand though. Why are we using background with the following code?

Code:
whileprintingrecords;
numbervar x := 0;
defaultattribute

I can understand it resets the counter but it does it everytime, even when I refresh the report.

So I took it off and now it doesn't reset the cumulative percentages back to Normal percentages.

Regards

Jehanzeb
 
In the original thread, the user had multiple instances of a column field and only wanted to sum particular columns and show the result in the total row. Your problem is a little different, and so you would have used the display string formula in the inner cells also, and with one column there is no need for a reset.

-LB
 
Yep! I have set it accordingly and it is working like a charm.

Man I love the way you fix people problems

Many thanks

Regards

Jehanzeb
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top