Focal Point
[SOLVED] MAX function or prefix whatever

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

September 10, 2010, 01:03 PM
Tracie Jones
[SOLVED] MAX function or prefix whatever
I am trying to get the MAX gift amount per person. Along with the corresponding gift code, gift designation, and gift date for that max gift. However when I put the MAX on the corresponding fields, it brings back the MAX based off of ABC order for that field. For example my max gift is 1000, with a designation of AFANNUAL. When I put the MAX on the desg field, it pulls back the designation with the latest letter of the alphabet, so let's just use ZEBRA as the designation. Also for the gift date, it is just bringing back the largest gift date, when I need the gift date of the largest gift. How can I achieve this?

This message has been edited. Last edited by: Kerry,


tbj
Prod WF 8.1.05,Test WF 8.1.05, WINDOWS 7 Platform, Oracle 12
Excel, PDF, Alpha
September 10, 2010, 02:04 PM
Darin Lee
The Max. designation only refers to the field on which it is placed, not the entire record. So for example, if you use MAX.MODEL and MAX.RCOST, you get the maximum value for retail cost, and the maximum (alphabetically last since it is an alpha field) value for model, but those two values will NOT correspond to the same record.

There are a couple of ways around this. One would be to sort by HIGHEST, HOLD, and then use the FST. prefix. This is the easiest/most straightforward, but requires a hold file.

You could also use a compute like

COMPUTE MAXGIFTDATE/YYMD=IF AMOUNT EQ MAX.AMOUNT THEN GIFTDATE ELSE '00000000';

(but then if there are two gifts with the same max value, there might be a problem.)

Third option is to use some combination of WITHIN in a COMPUTE to get the maximum value within a specific sort field.


Regards,

Darin



In FOCUS since 1991
WF Server: 7.7.04 on Linux and Z/OS, ReportCaster, Self-Service, MRE, Java, Flex
Data: DB2/UDB, Adabas, SQL Server Output: HTML,PDF,EXL2K/07, PS, AHTML, Flex
WF Client: 77 on Linux w/Tomcat
September 10, 2010, 03:29 PM
Tracie Jones
Thanks so much! I knew there was a simple answer. I will use the first option. Thanks again, and have a good weekend!


tbj
Prod WF 8.1.05,Test WF 8.1.05, WINDOWS 7 Platform, Oracle 12
Excel, PDF, Alpha
September 13, 2010, 12:43 PM
RSquared
You can also use BY HIGHEST 1. This approach does not require anything else. No hold as and fst.


WF 7.6.11
Oracle
WebSphere
Windows NT-5.2 x86 32bit
September 13, 2010, 01:58 PM
Darin Lee
But if you use BY HIGHEST 1, it has to be the highest 1 WITHIN the sort group - person in this case. Otherwise you just get one record returned. That was my last suggestion.


Regards,

Darin



In FOCUS since 1991
WF Server: 7.7.04 on Linux and Z/OS, ReportCaster, Self-Service, MRE, Java, Flex
Data: DB2/UDB, Adabas, SQL Server Output: HTML,PDF,EXL2K/07, PS, AHTML, Flex
WF Client: 77 on Linux w/Tomcat