Link to home
Start Free TrialLog in
Avatar of Clif
ClifFlag for United States of America

asked on

Pie Chart

I'm using Crystal Reports XI

I have five values that need to be represented in a pie chart.  These values are in five formulas.  I can get the values in the 'Show value(s)' list in the Chart Expert (and set the data read to 'for all records'), but the pie does not show up.  The legend shows 0% for each of the five values (with a Total: 100%).  I can drop the fields for each of the five formula right next to the chart, and the values do show up correctly.

What am I doing wrong, and how do I do it right?

Avatar of IanTh
Flag of United Kingdom of Great Britain and Northern Ireland image

Avatar of Mike McCracken
Mike McCracken

What are the formulas?

Avatar of Clif


IanTh -

I'm sorry, but I cannot view YouTube videos at work.


 mlmcc -

Fairly simple.  It's an addition of one or more of the individual field(s) totals.  What's returned in each field is a month's value (ie Balance_1 is for January, Balance_2 is February etc).  For the report (and chart) I need quarterly values, so I add Balance_1 + Balance_2 + Balance_3 for Q1.
Are they PRINTTIME formulas?
Do they have WhilePrintingRecords or use SHARED variables?

WHat does the raw data look like?

Avatar of Clif


Just as a test (and to be able to give y'all data to work with) I have created five simple formulas.  The only value in each forumula is as follows:
Name         Value
AATest_1     formula = 100
AATest_2     formula = 200
AATest_3     formula = 300
AATest_4     formula = 400
AATest_5     formula = 500

Open in new window

The chart is put in a Report Footer (RFb)

Adding 'WhilePrintingRecords' to the formulas doesn't help.
Avatar of James0628

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Clif


Curiously leaving WhilePrintingRecords off makes a difference.

Go figure!

CR processes reports in multiple passes.  I don't know off the top of my head what is done when, but the obvious guess is that building the chart is not done in the "print" pass, so including WhilePrintingRecords was keeping the formulas from being evaluated when the chart was being built.

 Which I imagine is why mlmcc asked earlier if your formulas were "print time" formulas.  I thought he was suggesting that they _should_ be print time, but now I'm guessing that he meant the opposite, and they should _not_ be.

 Anyway, I'm glad I could help (even if I had no idea what was causing the problem :-).

the printing pass is the last pass through the report.  grouping and charting is done earlier, thus print time formulas can't be used.

I tried what you did James and ended up with  single color chart and 0%.

Was that with or without WhilePrintingRecords in the formulas?  I did not include that.

You can't use print time (WhilePrintingRecords) formulas in a chart.

Just trying to clarify.  You said "I tried what you did James", but I did not include WhilePrintingRecords.  I'm guessing that you did, and that's why your chart didn't work.  If you did not include it, then I wonder why your chart didn't work?

I used a formula like
Name AATest_1    

Similarly for the others.

I don't know why it didn't work either

Interesting.  I just did some more experiments.

 If I create the chart using "For all records", I get no pie, and 0 % for each formula in the legend.

 If I change it to "For each record", I get a warning that the data and chart type don't match, and when I continue, I get a pie with slices and the correct %'s in the legend.

 If I undo that (Edit > Undo), it goes back to no pie and 0 %'s.

 But, if I go into the Chart Expert and change it from "For each record" back to "For all records" (instead of using Undo), the slices and %'s stay.  I don't know why, but they do.

 When I created the earlier chart, I remember trying both the "For each" and "For all" options, so that's probably why it worked for me.  I may have ended up with "For all", but I probably had used "For each" at some point, and that's why, in the end, "For all" worked for me.

 I tried saving a report with a "For all records" chart that was showing the pie and correct %'s, and when I re-opened the report and refreshed it, I still got the pie and %'s, so it wasn't just a temporary thing.

 I then added a new chart in that report (each chart in a separate report footer section) with "For all records", and it showed the 0 %'s, while the old chart with "For all records" was still showing the correct %'s.  I thought maybe the evaluation time for those formulas was somehow being changed, but I guess not, since the two charts produced different results.  It must be something in the chart itself.