• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 640
  • Last Modified:

Passing Formula to Subreport

Hi,

I have a problem.

I have a main report that has a Paramter Field "Year"

I have also two subreports which does a subreport link to the Parameter Field.

These subreports uses SQL Command and has parameter in the SQL query as "Reporting Year"

Now I want to modify the Parameter Field "Year" such that if I enter 2004, it will pass 2004 to the 1st subreport and 2003(Year-1) to the 2nd subreport.

I am able to use formula to do the subtraction but when I do a subreport link from this formula to the 2nd subreport, it does not show the 2nd subreport in the main report.

That is it is showhow hidden the whole 2nd subreport.

Is there a way to go about show both the subreports if I just enter 1 parameter field in the main report?

Thank you.
0
tansiakl
Asked:
tansiakl
  • 7
  • 3
  • 3
  • +2
1 Solution
 
frodomanCommented:
>>> when I do a subreport link from this formula to the 2nd subreport, it does not show the 2nd subreport in the main report

Sounds like there's something wrong with your linking.  Can you explain exactly what you've done?  You should be able to link your formula in the main report to your subreport and get the results you want.

>>> Is there a way to go about show both the subreports if I just enter 1 parameter field in the main report?

Of course - I have dozens of subreports based off a single parameter.  The problem is most likely in the linking but if you explain how you currently have the report laid out I can maybe help identify the issue.

frodoman
0
 
ebolekCommented:
you can do this with subreport linkig or shared variable

u already know the sub report linking so i wont explain more,

Shared variable solution
1. sharedvar yearvariable;
yearvariable  := field.{year};

put it in Mainreport  

2.Create second one
sharedvar yearvariable;
yearvariable;

Put this in subreport
It will have the valiue passed from the main report
0
 
tansiaklAuthor Commented:
Okie,

First of all, I have a main report without any database connection. It is just a empty shell to accept the "Year"

After the user enters the "Year" e.g. 2004, I have a formual {@Year-1} to calcalute and result 2003.

Then I have two subreports. Subreport 1 with SQL Command
Select
tblCal.Year, tblCal.Months, tblRevenue.Sales
From
tblCal, tblRevenue
Where
tblCal.key = tblRevenue.key AND
tblCal.Year = {?Reporting Year}

And the 2nd subreport with the same SQL Command.

I try to show some results from both subreport. No big deal here.

I do have my own reasons why I need to use 2 similar subreport. This is not a issue here.

Then I place the 2 subreports in the details section in the main report. And link the 1st report with the main report "Year" --> ?Reporting Year

And for the second subreport, I link formula "Year-1" --> ?Reporting Year.

I suppress all ther section in the main report.

I try to refesh the main report, the 1st subreport is okie but the second subreport is not show. However, if I put my mouse over where the 2nd subreport suppose to be, I can click on the space and it opens the 2nd subreport with any data.

If you want, you could do a simple test on Crystal without any tables and try to print some Special Fields to do some testing, the problem will appear.

If you want I can also send you a simple report on that.

Thanks
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

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

 
ebolekCommented:
are you sure that in the subreport change links you are selecting the correct parameetr field to use .
0
 
tansiaklAuthor Commented:
Hi ebolek,

THe problem is that I need to pass the parameter from the main report to the parameter in the subreport so that the subreport can run the SQL Command
Select ...
From...
Where Year = {?Reporting Year}

So a shared varible will not be useful in this case.

Correct me if I am wrong.
0
 
tansiaklAuthor Commented:
Hi ebolek,

I am sure I am selecting the right parameter field in the subreport bcos from my comment above, if I double-click on the subreport that is not show, it could display 2003.

Hope that helps.
0
 
ebolekCommented:
You are right
0
 
GJParkerCommented:
This is because the formula Year -1 will never be evaluated because your main report doesn't retrieve any data from the database.

There are 2 ways round this

1. Create a connection in your main report and return some data to the report (the field can be placed in a suppressed section) This will force the Year - 1 formula to evaluate in the main report.

2. Link the 2nd subreport to the Year paramater and then amend the command to

Select
tblCal.Year, tblCal.Months, tblRevenue.Sales
From
tblCal, tblRevenue
Where
tblCal.key = tblRevenue.key AND
tblCal.Year = {?Reporting Year} - 1

HTH

Gary

0
 
tansiaklAuthor Commented:
GJParker,

Your suggestion 1 is what I want.

It works now. Thanks.
0
 
GJParkerCommented:
Glad I could help

Gary
0
 
bdreed35Commented:
I know your problem has been resolved, but out of curiosity, would you mind sharing why you developed you report the way you did?  I mean, just from reading through this post, I see several different ways that you could have condensed this report into one.  I know that you weren't looking for feedback on that, but I was wondering why that you did it this way.

~Brian
0
 
tansiaklAuthor Commented:
Becos in the data mart we do not historize our monthly Sales Revenue. So now there is a to calculate my previous 12 months using formula.

For example, if the user enters 08/2004, then CR have to create 12 formula and 12 subreports so that the subreports can pass the Sales figures back to the main report. The result will look like:

09/2003  10/2003  11/2003  12/2003 ............................... 08/2004
$123       $112       $145      $245                                      $124

In this case what I have thought of is using 12 subreports to return each individual monthly sales revenue. And also we are using CR connection to SAP BW, so we can't actually modify the Query to the suggestion number 2 you give.

So the easiest way is to do the query 12 X.

Please let me know if you have better suggestions or views that you may want to share.
0
 
bdreed35Commented:
Is this a valid query for you to use:

Select
tblCal.Year, tblCal.Months, tblRevenue.Sales
From
tblCal, tblRevenue
Where
tblCal.key = tblRevenue.key AND
(tblCal.Year = {?Reporting Year} or tblCal.Year = {?Reporting Year} -1)


OR maybe a UNION would work:

Select
tblCal.Year, tblCal.Months, tblRevenue.Sales
From
tblCal, tblRevenue
Where
tblCal.key = tblRevenue.key AND
tblCal.Year = {?Reporting Year}
UNION ALL
Select
tblCal.Year, tblCal.Months, tblRevenue.Sales
From
tblCal, tblRevenue
Where
tblCal.key = tblRevenue.key AND
tblCal.Year = {?Reporting Year} - 1

If either of the two above work, you could condense it down to one report.

If either of thse work, than it might save you some work.  I am not sure what you mean about not keeping a history of the monthly Sales Revenue.  Where dio you get that information from for the report then?
0
 
tansiaklAuthor Commented:
Tis is a bit history so I will not go into why did we not have history tables.

Basically, the user needs to enter a month/year then the SAP BW will base on that value do some calcution and since everyday we will have differnet values, having a history tanles is not feasible.

And we cannot use UNION becos we are using SAP BW as the backend and it is not just some simple Oracle SQL as the SAP BW and ORacle is two different DB to start with.

Hope it helps.
0
 
bdreed35Commented:
Ok, since I don't have experience with SAP, I will have to trust you.  Sounds like it is very constricting.

Well, at least you got your inital problem resolved.
0
 
tansiaklAuthor Commented:
Yeah,

Thanks for all your feedback and suggesiton though.
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 7
  • 3
  • 3
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now