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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Make grouping depending on selected parameter

Status
Not open for further replies.

Cores

Programmer
Oct 17, 2007
92
CA
Hi Dear Experts,
I am using Crystal Reports for Enterprise.

Is it possible to change grouping depending on selected parameter?

There are two Multi-select Parameters: 1)Programs 2)Regions or "ALL".
Main Report has two groups - Programs and Regions. Main report has no data, only grouping.
Sub-report is located in GF2 (Regions) to display data for every program and every region. All works correctly.

How to make the report would have only one group (Programs) if "ALL" is selected for Regions parameter. The user wants if "ALL" regions is selected, the report is grouped only by Programs summarizing data for all regions.

I tried placing a copy of sub-report in GF1(Programs), and removed Region parameter link, but the report is still is grouped by regions.

How to group report only by Programs if "ALL" regions option is selected?

Thanks very much!!!
 
Change your group #2 so that it groups on a formula instead of the region field:

If {?Parm} <> “All” then
{table.region} else
“”

This assumes region is a string. Be sure to replace my iPad quotes with your own.

-LB
 
Thank you very much for your quick response and your help.

But two problems still exist. First, running the report takes a much longer time to run - maybe because I added a second sub-report.
With the formula you suggested, the report was summarizing data for all regions (if "ALL" regions is selected), once the filters between main report and sub-report is Programs only. But in that case, the report was also summarizing if not "ALL" option for regions parameter was selected.

Then I placed another sub-report where there are two filters between main and subreport - Programs and Regions. The second sub-report displays grouping by Program and by Region and it is hidden once "All" option is selected.

The second problem is sorting by Regions. Before, I used a custom grouping for Regions as user wanted. Now, when Regions grouping in the formula, I cannot control the order how the regions are listed to be displayed in report. Linda, from your experience, is it possible to insert somehow sorting of regions? The user wants the regions to be displayed starting from east of the country to west, not alphabetically as it is displayed now.

Thank you.
Cores
 
You can always do a specified order grouping in Crystal Reports. Can be rather tedious to set up.
 
What is your rationale for using subreports? Why can’t you simply link the relevant tables?

-LB
 
I am using sub-reports because the user wants to add to existing report an ability to select multiple programs and regions. In original report, the user could select only data for one program and one region or "All" regions option. Selecting multiple programs and regions, they want to display data in report for one program and one region on every page. For ex., if three programs and four regions is selected then the report will have 12 pages. And summarizing data can be done only once the "ALL" regions option is selected.

The original report has two charts in report header, column headings in Page Header and summarizing data in group and report footer. The group is Month Name- the report displays percentage performance changes over months. That's why I wrapped the original report and placed it as sub-report (actually two sub-reports) in empty main report. And added two groups in main report - Programs and your formula (instead of Regions).
The data is displayed correctly and as expected. Only, the problem is running time now.

kray4660,
thank you for the idea for custom sorting. I added the custom sorting to the formula suggested by lbass.
Thank you very much to both of you.
 
This is hard to follow, but I am not convinced of the need for two subreports. (Or any). However, if speed is your only remaining issue, then you should compare the SQL statements with your selection formulas in each subreport and in the main report, to make sure that everything is passing to the SQL statements.

I also think you should be conditionally suppressing, not hiding, any sections, since they will still need to be compiled if only hidden.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top