Solved

Calculated field based on subreport ... AGAIN

Posted on 2014-11-19
2
177 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

839 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