Technical Articles
Charting off of Any Number in Crystal Reports
You may have a Crystal Report that has a WhilePrintingRecords formula. It is not possible in Crystal Reports 2008 and below to create a chart directly off of that formula due to evaluation times. Don’t despair though, as here’s a way to chart off of these values.
This blog post and sample report will show you how to chart off of the values you have in any WhilePrintingRecords formula.
- In this sample, shared variables created on a details level subreport are to be graphed on.
- Group values (in this case Customer names) are rolled up into a string running total that is character separated.
- Values that are to be graphed on are rolled up into another string running total which is also character separated.
- A subreport is created and then linked on the two above-mentioned formulae.
- The subreport parses out the values in the Value RT running total to create the graph.
- The Group RT formula can be used in the subreport’s record selection formula to limit the number of records that will be shown in the graph and hence the number of records returned in the subreport.
Below is a screenshot from the sample report.
all of the data that is needed in the chart is rolled up into the string running total and each value is separated by the "^" symbol. the string running totals are passed to a subreport, via a subreport link, and a "split" function is used to parse out the values both in the record selection formula and in a formula which is used in the chart Show Values.
Example from one of your formulas:
shared grouprt as string
grouprt = grouprt + {Customer.Customer Name} + "^"
if onlastrecord then formula = "^" + grouprt else formula = grouprt
in regular crystal syntax the formula result is always the last bit of code in the formula. however, in crystal basic syntax, the formula operator designates what will actually be the formula result regardless of what is at the bottom of the formula.
this can be an advantage in basic syntax as you can assign different values to a variable after that variable has been printed / made available to other formulae.
It seems it would solve all my current problem. However, I still dont understand How you parse the the string separated by "^". How to you give it to the chart and how do you split it on "^"
If I create a variable making the split, it return an array (which is not allowed as an error message is coming)
cheers
lionel