Focal Point Banner
Community Center Education Summit Technical Support User Groups
Let's Get Social!

Facebook Twitter LinkedIn YouTube
Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] MAX function or prefix whatever
Go
New
Search
Notify
Tools
Reply
  
[SOLVED] MAX function or prefix whatever
 Login/Join
 
Platinum Member
posted
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
 
Posts: 126 | Location: Chapel Hill, NC | Registered: October 24, 2006Reply With QuoteReport This Post
Virtuoso
posted Hide Post
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
 
Posts: 2298 | Location: Salt Lake City, Utah | Registered: February 02, 2007Reply With QuoteReport This Post
Platinum Member
posted Hide Post
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
 
Posts: 126 | Location: Chapel Hill, NC | Registered: October 24, 2006Reply With QuoteReport This Post
Guru
posted Hide Post
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
 
Posts: 398 | Registered: February 04, 2008Reply With QuoteReport This Post
Virtuoso
posted Hide Post
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
 
Posts: 2298 | Location: Salt Lake City, Utah | Registered: February 02, 2007Reply With QuoteReport This Post
  Powered by Social Strata  
 

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] MAX function or prefix whatever

Copyright © 1996-2018 Information Builders, leaders in enterprise business intelligence.