@ DBlank,
Thanks for your response. I spent the better part of yesterday trying different things with groups and group sorts. I'm having trouble getting this to work. I'm new to CR and have no training in it, but I do want to learn. Let me explain how this report is setup.
I open the report in CR. It looks like this:
Report Header(no information in this section and it is suppressed)
Page HeaderPrint Date field and Text Objects for Report Title and Column Titles
Group Header #1Sub-report titled "Sales History by Customer_Sub.rpt"
Details(no information in this section and it is suppressed)
Group Footer #1(no information in this section and it is suppressed)
Report FooterSub-report titled "MTD_YTD_Sales". (This is just a Grand Total at the end of the report for all sales for all customers for both the current and the prior year. This one appears to be working properly.)
Page FooterPage N of M field and Text Object with file name.
The data by which I want to sort is the data returned by the Sales History by Customer sub-report. I open that up and it looks like this:
Report Header(no information in this section and it is suppressed)
Group Header #1(no information in this section and it is suppressed)
Details(no information in this section and it is suppressed)
Group Footer #1Field: CustID_23
Field: CustName_23
Formula: Adj_YTD_Invoices_LastYr
Formula: Adj_YTD_Invoices
Report Footer(no information in this section and it is suppressed)
The Sub-report Links CUSTID_23 to parameter ?Pm-Cust_Master.CUSTID_23 and 'Select data in subreport based on field:' is checked and Cust_Master.CUSTID_23 is selected.
The formulas in the sub-report are as follows:
Adj_YTD_Invoices:sum({@CalcYTDInvoices})-sum({@CalcYTD_Credits})
Adj_YTD_Invoices_LastYr:Sum({@CalcYTDInvoices_LastYr})-Sum({@CalcYTD_Credits_LastYr})
CalcYTDInvoices:if({Inv_Master.INVDTE_31} in YearToDate)
and {Inv_Master.STYPE_31}='CU'
then
{Inv_Master.LNETOT_31}-({Inv_Master.ORDDSC_31}
CalcYTD_Credits:if({Inv_Master.INVDTE_31} in YearToDate)
and {Inv_Master.STYPE_31}='CR'
then
{Inv_Master.LNETOT_31}
CalcYTDInvoices_LastYr:if({Inv_Master.INVDTE_31} in LastYearYTD)
and {Inv_Master.STYPE_31}='CU'
then
{Inv_Master.LNETOT_31}-({Inv_Master.ORDDSC_31}
CalcYTD_Credits_LastYr:if({Inv_Master.INVDTE_31} in LastYearYTD)
and {Inv_Master.STYPE_31}='CR'
then
{Inv_Master.LNETOT_31}
The main report has a Group Sort that is sorted by @CalcYTDSales which does get the information in
almost descending
order. What I mean is that the results are largely in descending value
by the Adj_YTD_Invoices amounts. It starts off with the three largest
amounts in the correct order then the 10th largest, then 5th, 4th, 6th,
7th, 13th, 14th, 11th, 8th, 12th, 9th. You get the idea. It does mostly straighten out a few pages into the report.