Pie Chart

Clif
Clif used Ask the Experts™
on
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?

TIA
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Mike McCrackenSenior Consultant
Most Valuable Expert 2011
Top Expert 2013

Commented:
What are the formulas?

mlmcc

Author

Commented:
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.
Exploring ASP.NET Core: Fundamentals

Learn to build web apps and services, IoT apps, and mobile backends by covering the fundamentals of ASP.NET Core and  exploring the core foundations for app libraries.

Mike McCrackenSenior Consultant
Most Valuable Expert 2011
Top Expert 2013

Commented:
Are they PRINTTIME formulas?
Do they have WhilePrintingRecords or use SHARED variables?

WHat does the raw data look like?

mlmcc

Author

Commented:
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.
If you use those 5 formulas (AATest_1, etc.) in a pie chart in the report footer, with "For all records", you don't see a slice for each formula, with the expected %'s (6.7, 13.3, 20, etc.) in the legend?  That seems to work fine here.  FWIW, I did not include WhilePrintingRecords in the formulas.  I just put the number (100, 200, etc.) in each formula.

 James

Author

Commented:
Curiously leaving WhilePrintingRecords off makes a difference.

Go figure!

Thanks.
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 :-).

 James
Mike McCrackenSenior Consultant
Most Valuable Expert 2011
Top Expert 2013

Commented:
the printing pass is the last pass through the report.  grouping and charting is done earlier, thus print time formulas can't be used.
http://www.sdn.sap.com/irj/boc/go/portal/prtroot/docs/library/uuid/204c3492-ab1e-2b10-b683-b5e8fe390d70?QuickLink=index&overridelayout=true&29665339124315

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

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

 James
Mike McCrackenSenior Consultant
Most Valuable Expert 2011
Top Expert 2013

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

mlmcc
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?

 James
Mike McCrackenSenior Consultant
Most Valuable Expert 2011
Top Expert 2013

Commented:
I used a formula like
Name AATest_1    
  100

Similarly for the others.

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

mlmcc
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.

 FWIW:
 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.

 James

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial