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

Top N/Bottom N same report

Status
Not open for further replies.

GCL2007

IS-IT--Management
Dec 11, 2007
167
US
I currently have 2 separate reports, which are basically the same except for one is a Top N, the other reports Bottom N. I've been asked to consolidate into one report.
So, I added an additional GF section, added a parameter as to which summary I wanted, Top or Bottom, and tried to suppress either GF1 or GF2 depending on the result of the summary parameter. GF1 and GF2 are essentially the same...
I thought this might work, but it looks like I am only getting the Top N.
Any thoughts or better way to handle this? Thanks!!
 
Hi,

If it's that big of problem why can't't you have two rpt files. Why should that be a problem.
Anyway, if you just have to have only ne report why not create a temporary table or a view, or if you are working on .net create a dataset, and just fill it with data frm a select statement like
select top 5 count(customer_id)
from invoice
group by customer_id
order by count(customer_id) ASC // or desc depnding on do you want top 5 or bottom 5
and you built a report on that tbale/view/dataset.
That's the easiest way for me..
I hope it helps..
Regards
Armin

Kind regards
Armin
 
I don't think the same report can do both, except using a subreport. Save the report under a different name, then re-import it as a subreport in the report header or footer. Edit > Subreport Links can be used to pass on parameter, but note that this adds the link as a record-selection in the subreport, additional to any test you already have.

[yinyang] Madawc Williams (East Anglia, UK). Using Windows XP & Crystal 10 [yinyang]
 
You can do this by creating a parameter {?Sort} with two options: "TopN" or "BottomN". Create two formulas:

//{@topN}:
if {?Sort} = "TopN" then {table.amt}

//{@bottomN}:
if {?Sort} = "BottomN" then {table.amt}

Place these in the detail section and insert summaries on them, and then go to report->Group Sort and add {@TopN} as you first group sort field, descending order, and then add {@BottomN}, ascending order, as your second sort field.

Since the default is 0 in each formula, if the parameter is not selected, all records will have a zero value and will not have an impact on the sort by the other field. You can suppress the summaries for these formulas and just display the actual summary in the report.

-LB
 
I left out a step. When you set up the group sorts, you would choose "All". You would also need to create a number parameter {?N} and then in the section expert, conditionally suppress the group section being sorted by using a formula:

groupnumber > {?N}

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top