Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Struggling for a solution

Status
Not open for further replies.

kmcclung

Programmer
Nov 20, 2001
120
US
I am currently fighting to create a report and cannot seem to generate what I'm looking for. I'm hoping for some ideas or input.

The report is of the reasons why a customer called and the corresponding resolution to the call by day with a MTD total. This sounds easy enough, but the layout the customer is requesting is what makes it difficult. They would like to see a list of ALL reasons with a list of ALL resolutions below each reason, regardless of whether a call for that reason &/or resolution was logged.

The report would look like this:

Total Calls/Day Total Calls MTD
Reason #1
Resolution #1
Resolution #2
Resolution #3
Resolution #4

Reason #2
Resolution #1
Resolution #2
Resolution #3
Resolution #4

And so on. The resolution descriptions are the same for every reason.

So far I have a main report that displays the reason descriptions (from one table) as Group #1 and the resolution descriptions (from another table) as Group #2. Joined by a customer id field.

I then created a sub report that displays the reason & resolutions for a particular day with the count for each:

Total Calls/Day Total Calls MTD
Reason #1 5 15
Resolution #2 5 15

Reason #5 4 20
Resolution #3 1 12
Resolution #4 3 8

Reason #7 3 5
Resolution #2 2 2
Resolution #4 1 3

I created a shared variable of the reason @CallReason and the count of the calls by reason @ReasonCount in the subreport. I added them to the main report and tried to create a formula where if the @CallReason = MainReport.Reason, then display @reasonCount else display 0.

But the @ReasonCount does not display. I also tried just displaying the reason description if the values matched and still nothing.

Any ideas?????
 
Post the actual formulas you are trying.
Also, where is the subreport placed in the main report?

A subreport with a shared variable will only send back one value for each variable. Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guide to using Crystal in VB
tek@kenhamady.com
 
I have the subreport in the Report Footer a, with the shared variable in the Report Footer b.

The formulas are as follows:
//@CallReason (SubReport)
WhilePrintingRecords;
shared stringVar CallReason := trim({tablename.CALL_REASON_DESC});

//@CallReason (Main)
WhilePrintingRecords;
shared stringVar CallReason;

//@ReasonCount (SubReport)
Shared numberVar ReasonCount := Count ({tablename.CALL_REASON_DESC}, {tablename..CALL_REASON_DESC});

//@ReasonCount (Main)
shared numbervar ReasonCount;

I am able to pass the shared variable and display it in the Report Footer b, which is when I realized it is only passing the last value from the sub report. Is there any way to pass a shared array to solve this problem? Or another workaround?

Thanks!
 
You could bring back an array, but you would only be able to use it at the end of the report. If you are trying to bring back a separate subreport value for each GROUP of the main report, then you will need a linked subreport placed in the group header or footer. The subreport will run with each group and bring back a single shared value. Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guide to using Crystal in VB
tek@kenhamady.com
 
I've started down that road but still cannot seem to get the expected results. I had moved the subreport to the Group Footer b, added a formula that displays true if the value passed from the subreport matches the group (DESCRIPTION) in the main. It is as follows:
if {@Call Reason} = {tablename.DESCRIPTION} then
true
else
false

It displays "true" for the last variable returned from the sub report, but not for the other values (displayed as Groups in the sub report also). (In other works, it doesn't appear to be bringing back a separate subreport value for each group.) I added @CallReason to the Group Footer b and it displays the last value returned from the subreport each time. Is this because the sub report is not linked? If it may be, can you provide some insight into linking? I have not worked with this before and am not sure the Crystal Help makes much sense to me.

Thanks for your help!!!
 
I added a link by the DESCRIPTION (Group Header #1) in the main report to the description (Group Header #1) in the sub report. This appears to have cleared up some issues. The display of the @CallReason in the Group Footer b now displays only 1 value from the subreport, but not correctly. The value is blank until the first value displayed in the sub report matches the DESCRIPTION in the main report. (Which is correct, however the boolean formula is always false - even if the @CallReason = DESCRIPTION [Group Header #1].) It also continues to display the last value found in the subreport in the Group Footer b, until the next value found matches the DESCRIPTION. And so on....

Any ideas? I think I have the link set up correctly though.
 
The description of the problem in your message above is a bit confusing, but I suspect the problem is due to placing the linked subreport in Group Footer b instead of in
Group Footer a.

In other words, make sure the shared variable in the main report is placed AFTER the section with the subreport responsible for setting that variable's value.

This is due to the fact that the variables in each section
are processed before the subreports in that same section.

Cheers,
- Ido ixm7@psu.edu
 
The shared variable @CallReason is located in the proper order. In the main report it is located in Group Footer #1b, with the subreport located in Group Footer #1a.

Thanks for the feedback.
 
The link should create a parameter in the subreport. Use this paremter in the select expert of the subreport, so that each subreport only selects records that match that gruop.

Also, the shared variable in the main report should be in the section AFTER the subreport. Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guide to using Crystal in VB
tek@kenhamady.com
 
I mis-typed in a post above, but the subreport is in Group Footer #1a and the shared variable (@CallReason) is in the Group Footer #1b.

I also created the subreport link and added the parameter to the Select Expert in the subreport. This works except I am still encountering the problem I described above.

The first few groups of the main report don't display the subreport nor a value for the @CallReason (and display a zero for the shared variable, @CallCount I added, on the count of the description from the subreport) because the parameter condition isn't met - this is correct and looks great.

Then, the first time the parameter matches, the subreport displays in Group Footer #1a and the @CallReason displays in Group Footer #1b with the @CallCount shared variable - again, correct and looks great.

However, the next several groups in the main report don't meet the parameter condition but the @CallReason & @CallCount still display in the Group Footer #1b, but the subreport doesn't display in the Group Footer #1a (which it shouldn't). The values displayed only change the next time the parameter condition is meet, which again displays correctly but the next group that doesn't match displays the previous groups info (that did match) in the Group Footer #1b.

I sincerely hope this is making sense and I apologize for any confusion! Thanks again!
 
Just reset the shared variables in the group header.

This way they won't carry over from the previous group.

Cheers,
- Ido ixm7@psu.edu
 
You need to clear the shared variable (assign it the value "") at the beginning of each group in the main report(in the GH). That way it doesn't simply carry the value forward from the last value it was assigned. Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guide to using Crystal in VB
tek@kenhamady.com
 
Thanks - that worked. And I now seem to be getting the expected results. I now have to do this all over again for the Group #2 (the call resolution - where Group #1 was the reason for the call). I should be able to tackle this in the same way using the same report, but may be back for more advice.

Thanks again for your support!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top