Focal Point
2 Primary sort fields

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/3081026012

January 31, 2007, 10:08 AM
Anurupa
2 Primary sort fields
Hello,
___________________X X
A________ B________-- --
__________________-- --
__________________-- --
__________________-- --
__________________-- --
__________________-- --
__________________-- --

I would like to be able to sort the values of the same column X by column A and by column B. However, both must be primary sorts, to be able to compare the two resulting X columns.
Is this possible? Or, has anybody needed something like this, and found another way around it?
Thanks!

This message has been edited. Last edited by: Anurupa,
January 31, 2007, 10:14 AM
codermonkey
Could you please clarify what you are looking for? I'm not sure I understand what you require. Are there 3 columns -- X, A, and B? Or are A and B values in column X.
January 31, 2007, 10:25 AM
Anurupa
I apologize - I hadn't realized that my illustration didn't go through as expected. I've changed it now - hope it makes more sense.
A and B are the 2 sort columns, and there need to be 2 columns of the same field X.
January 31, 2007, 01:22 PM
codermonkey
Thanks but still not sure I understand. Would concatenating A and B and sorting on that get you what you need? NOTE:there may be optimizating repercussions to sorting on a DEFINE.
January 31, 2007, 01:41 PM
Anurupa
I need A and B to remain separate, and I want to
[1] sort X based on sort field A,
[2] sort X based on sort field B,
and be able to compare columns [1] and [2].
January 31, 2007, 01:54 PM
FrankDutch
TABLE FILE CAR
PRINT
A
B
X
Y
BY A NOPRINT
BY B NOPRINT
END
A rather basic report, but I think we do not understand what you want.




Frank

prod: WF 7.6.10 platform Windows,
databases: msSQL2000, msSQL2005, RMS, Oracle, Sybase,IE7
test: WF 7.6.10 on the same platform and databases,IE7

January 31, 2007, 02:08 PM
codermonkey
Are A and B the same field but from different tables? This would be the only way what I think you want to do makes sense.

Either way, I think what you want you can get with MATCH FILE. Just know that if field A and field B do not represent a common sort field, the data will get merged with no regard to matching since there is no relationship between A and B.

MATCH FILE tablename
PRINT X
BY A
RUN
FILE tablename
PRINT X
BY B
AFTER MATCH HOLD OLD-OR-NEW
END
TABLE FILE HOLD
PRINT *
END

Look up MATCH and concatenating without a common sort field in the manual for more info.
January 31, 2007, 02:34 PM
mgrackin
SET ASNAMES=ON

TABLE FILE CAR
PRINT COUNTRY CAR
COMPUTE THELIST/I1=1;
COMPUTE CNTR/I5=LAST CNTR + 1;
BY HIGHEST RCOST AS 'COST'
ON TABLE HOLD AS LISTONE
END

TABLE FILE CAR
PRINT COUNTRY CAR
COMPUTE THELIST/I1=2;
COMPUTE CNTR/I5=LAST CNTR + 1;
BY HIGHEST DCOST AS 'COST'
ON TABLE HOLD AS LISTTWO
END
-RUN

DEFINE FILE LISTONE
LISTNAME/A16=
DECODE THELIST(1 'Retail Cost Sort' 2 'Dealer Cost Sort');
END
DEFINE FILE LISTTWO
LISTNAME/A16=
DECODE THELIST(1 'Retail Cost Sort' 2 'Dealer Cost Sort');
END

TABLE FILE LISTONE
SUM COST COUNTRY CAR
BY CNTR
ACROSS THELIST NOPRINT
ACROSS LISTNAME
MORE
FILE LISTTWO
END


Thanks!

Mickey

FOCUS/WebFOCUS 1990 - 2011
January 31, 2007, 02:38 PM
mgrackin
I like the MATCH FILE better. I tried to come up with a MATCH FILE example but didn't think it would work if the sorts were different. I was wrong.

Here's an example:

MATCH FILE CAR
PRINT CAR
BY HIGHEST RCOST
RUN
FILE CAR
PRINT CAR
BY HIGHEST DCOST
AFTER MATCH HOLD OLD-OR-NEW
END
TABLE FILE HOLD
PRINT *
END


Thanks!

Mickey

FOCUS/WebFOCUS 1990 - 2011