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!

BY: how to make a sort of its own, not alphabetically 1

Status
Not open for further replies.

kaeserea

Programmer
Feb 26, 2003
164
DE
Hello!

using the BY Phrase the columns are always sorted alphabetically. Yet in most reports I have to create I need a different sort (mostly arbitrary and doesn't follow a pattern). Those sorts occur only when I have about 2 to 5 values within the column used for sorting the data.

I know I can change the order by using SET STYLEMODE=FIXED and then use IN and shuffle the alphabetical order created by BY. But how can I do this without a FIXED Stylemode?

Eva
 
Eva,

You can simply use DEFINEd field, to sort on it.
This is a simple example:

DEFINE FILE CAR
WEIGHT/I5 = IF CAR EQ 'TOYOTA' OR 'AUDI' THEN 1 ELSE
IF CAR EQ 'BMW' THEN 2 ELSE 3;
END

TABLE FILE CAR
SUM SALES
BY WEIGHT NOPRINT
BY CAR
END

Hope this helps
Grzegorz
 
Hi Grzegorz,

Great. Nice trick and it works perfectly. Thanks a lot.

Eva
 
An even easier way is to use the 'ROWS' keyword:

DEFINE FILE CAR
WEIGHT/I5 = IF CAR EQ 'TOYOTA' OR 'AUDI' THEN 1 ELSE
IF CAR EQ 'BMW' THEN 2 ELSE 3;
END

TABLE FILE CAR
SUM SALES
BY WEIGHT NOPRINT
BY CAR
ROWS TOYOTA OR AUDI AS 'LABEL1' OVER BMW AS 'LABEL2' OVER ...
END
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top