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

Range Variable(s) example 1

Status
Not open for further replies.

blueboyz

Technical User
Joined
Sep 13, 2005
Messages
210
Location
US
I am using Crystal v9 with Peachtree 2006/Brtrieve.

I am trying to understand Range Variable(s).

If I create a report that places sales amounts into specific ranges and then groups on those ranges so a count can be done for customers in each group, do I use a range variable to accomplish this?

I want groups of sales amounts from 0 to 1000, then 1001 to 2000 and then 2001 to 5000.

Would I create the range variables like the following:
{@Sales1000}
WhilePrintingRecords;
NumberVar range Sales1000;
Sales1000 := 0 to 1000;
0

{@Sales2000}
WhilePrintingRecords;
NumberVar range Sales2000;
Sales5000 := 1001 to 2000;
0

{@Sales5000}
WhilePrintingRecords;
NumberVar range Sales5000;
Sales5000 := 2001 to 5000;
0

and then place the formulas in the Group header #1: {Customers.SalesThisYear}.

I've tried grouping on the {Customers.SalesThisYr} and customizing the group name, but it's not creating the groups correctly.

I want the data to show:

ID Name Sales
$0 to $1000: 3
A Company A $500
D Company D $799
K Company K $640

$1001 to $2000: 3
B Company B $1500
E Company E $1800
I Company I $2000

$2001 to $5000: 4
C Company C $2500
F Company F $5000
G Company G $7000
H Company H $3000

Any help is appreciated.
 
Is {Customer.SalesThisYear} a database field? And are the company records you show at the detail level or are they summaries?

-LB
 
That isn't how grouping works in Crystal nor in databases/SQL.

Create a formula of:

//Name it something like SalesGroup
//@SalesGroup
if {table.sales} <= 1000 then
"$0 to $1000:"
else
if {table.sales} <= 2000 then
"$1001 to $2000:"
else
if {table.sales} <= 5000 then
"$2001 to $5000:"
else
if {table.sales} > 5000 then
"$5000+:"

Now you can use this field to group on.

Now place the fields in the details, right click the ID field and select Insert->Summary->Count and select it to be placed in the @SalesGroup field.

It will place it in the group footer, drag it to the group header alongside the automatically placed group header field.

Right click the group footer and select Suppress.

It should look like your desired output now.

I think that you were the same person asking about range variables earlier, I suggest that in the future you NOT designate architecture, simply state your environment and requirements until you get a better understanding of Crystal, in general this means:

Crystal version (did this)
Database/connectivity (did this)
Example data (show what's in the tables)
Expected output (did this)

I think that your requirements are straightforward enough, so the above should suffice.

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top