Solved

Calculated field based on subreport ... AGAIN

Posted on 2014-11-19
2
179 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Crystal Reports 2008 6 42
Crystal Reports CSV data source, field types 6 175
Possibly a grouping issue? 7 36
Multiple Line Graph in Crystal Report 2013 9 36
I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

726 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