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

can I chart on variables?

Status
Not open for further replies.

ramc2000

Technical User
Nov 8, 2002
60
GT
I need to chart the data from a report where I've created a manual crosstab. The 5 columns in my report are displaying the contents of 10 different counter variables I have defined.

My report looks like this:

range1 range 2 range 3 range4 range5
store1 @formula1 @formula2 @formula3 @formula4 @formula5
store2 " " " " "
store3 " " " " "
Totals @formula6 @formula7 @formula8 @formula9 @formula10

@formula1 contains the following:
whileprintingrecords;
numberVar Range1;

and @formula6 contains:
whileprintingrecords;
numbervar Rango6Total;

All this formulas are assigned values in the details section of my report.

I need to chart the percentage the values in @formula6 through @formula10 represent compared to the grand total.
How can I get CR 8 to chart this data? the problem is that since these columns are all variables and not table fields, I can't use the "On Change of" drop down list in the chart expert to chart a value each time the range changes.
Any help will be greatly appreciated.
 
ramc2000,
If you want to make a graph on a while printing record formula i can send you a sample report that will show you how you can do this. It is somewhat complex, and it takes a little while to set up. Email me to request this copy at jdecker@gentex.com
DecHer
 
The reason you can't chart on the formulas is because they are WhilePrintingRecords formulas. Are you sure they need to be?

Explain a little more about the calculation involved in the formulas and perhaps there's a way around this.

DecHer's sample report may be more complex than you need although I'll be requesting a copy from him too! Steve Phillips, Crystal Consultant
 
I'm pretty sure the formulas need to be whileprintingrecords formulas, otherwise I get only zeros
in my report!! Altough if there's a way around this, I'd be more than happy to try it.

Basically the calculation I'm doing is the time elapsed (in days) between the moment our warehouse ships out an order to a customer and the moment we receive such order, also the report is grouped by customer:

//@Difference
Int ({DateOrderShipped}-{DateOrderReceived})

Then I use the following routine to count the number of orders that fall into predefined ranges of time elapsed (ie.: how many orders were delivered one day earlier than expected, at the exact day expected, one day after and so on.)

//counting number of orders
whileprintingrecords;
numberVar Range1;
numberVar Range2;
numberVar Range3;
numberVar Range4;
numberVar Range5;

numberVar Range1Total;
numberVar Range2Total;
numberVar Range3Total;
numberVar Range4Total;
numberVar Range5Total;

//Sums one if the order falls into each range

select {@Difference}
case Is <-2:
(Range1:=1+Range1;
Range1Total:=1+Range1Total;)
case -2, -1:
(Range2:=1+Range2;
Range2Total:=1+Range2Total;)
case 0:
(Range3:=1+Range3;
Range3Total:=1+Range3Total;)
case 1,2:
(Range4:=1+Range4;
Range4Total:=1+Range4Total;)
case is >2:
(Range5:=1+Range5;
Range5Total:=1+Range5Total;);

The @formula1 to @formula5 above correspond to range1 to range5 variables (which I reset at the group header level)and @formula6 to @formula10 correspond to Range1Total to Range5Total (which are never resetted).
And as I noted above I want to chart the percentage the values in range1Total to range5Total represent compared to the total number of orders.
I hope this can give you a better perspective of what I want to accomplish, any help will be appreciated it. Thank you.
 
You are using variables when you don't need them.

Write 5 formulas that are:

if {@Difference} < -2
then 1
else 0

Then subtotal (sum) and grand total (sum) thes formulas.
Do the same for each columns.

Because these are now regular summary fields they can be charted. Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guide to using Crystal in VB
tek@kenhamady.com
 
You see what I mean now.

There are many cases where you can avoid using variables that get calculated at the WhilePrintingRecords phase and this is one of them.

Ken's suggested solution is exactly what you need.

It makes the final report a little easier to write! Steve Phillips, Crystal Consultant
 
A slightly simpler approach would be to use a single formula (using a CASE statement) that returns a different range label for each of the five possible ranges.

Now you are free to simply create a CrossTab at the Group Level and/or Report Level showing counts and/or totals for each Range category.

Note: be sure to name these Range Labels in a manner that sorts as you would expect it (to ensure they appear in the CrossTab in the order you expect).

Cheers,
- Ido CUT, Visual CUT, and DataLink Viewer:
view, e-mail, export, burst, distribute, and schedule Crystal Reports.
 
I forgot to mention that you can base your chart directly on the CrossTab (or Group the report on the Range category to allow a Chart without a CrossTab).

hth,
- Ido CUT, Visual CUT, and DataLink Viewer:
view, e-mail, export, burst, distribute, and schedule Crystal Reports.
 
Except that CR 8 can't put percentages in a cross-tab.
It can, however, show them in the chart. Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guide to using Crystal in VB
tek@kenhamady.com
 
Thank you all!! I took a bit from each reply and now I have a beautiful report with a chart just the way I wanted it.

Just in case you are wondering, this is what I finally did:

select {@Difference}

case is <-2:
&quot;Range1&quot;
case -1,-2:
&quot;Range2&quot;
case 0:
&quot;Range3&quot;
case 1,2:
&quot;Range4&quot;
case is >2:
&quot;Range5&quot;

And then, I inserted 5 formulas like the following:

if {@SelectRange}=&quot;Range1&quot; then
1
else
0

Again, thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top