Solved

Calculated field based on subreport ... AGAIN

Posted on 2014-11-19
2
173 Views
Last Modified: 2014-11-19
I thought this was working correctly, but it's not.  I'm having difficulty getting a field from my subreport and using it in a formula in my main report.

In my subreport, I have a formula called Subreporttotal in the Group Footer #1, that is :
WhilePrintingRecords;
Shared NumberVar SubreportTotal;
SubreportTotal := Sum({Command.ext_recvd}, {Command.vendor_id});

In my main report I have formula called SharedNumberVar that is in the report header that is:
WhilePrintingRecords;
Shared NumberVar SubreportTotal;

In my main report, I have a formula called Impact %, that is in the Group Footer #1 @ Vendor - A section that is:
WhilePrintingRecords;
Shared NumberVar SubreportTotal;
If SubreportTotal = 0 then
    0
Else
    Sum ({@Total NC Cost}, {@Vendor}) / SubreportTotal


When I run the report, I get zeros everywhere and I can't figure out what I have done wrong.
Vendor-Issues---Summary.rpt
Vendor-Spend-Subreport.rpt
Vendor-Name-Subreport.rpt
0
Comment
Question by:ITworks
2 Comments
 
LVL 100

Accepted Solution

by:
mlmcc earned 500 total points
ID: 40452364
I found 3 issues with your implementation

1.  You didn't have a formula in the subreport that assigned a value to the shared variable.

2.  You are calculating a % but you weren't displaying any decimals so all values were rounding down to 0.  ALso since it is a % the formula needed to be multiplied by 100.

3.  Subreports are the last object evaluated in a section.  Since your formula relies on a value returned from the subreport it needs to be in a section after the subreport.  I added a GF1b and put the formula there.  To make it look like it is on the same line as the rest I set GF1a to underlay the following section.

I also changed the formula in the report header so it declares the shared variable but doesn't show any values.

The attached report has my changes.  I couldn't save it with data since apparently there is more data than was saved with it.

mlmcc
Vendor-Issues---SummaryRevA.rpt
0
 
LVL 4

Author Closing Comment

by:ITworks
ID: 40452394
Thanks so much!  I will add all of your help to my 'help file' for future reference.   This was my first report with variables.....I learned a lot from you.
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now