Focal Point
[SOLVED] Decode function

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

January 16, 2009, 06:42 PM
Learner
[SOLVED] Decode function
Hi everyone,

I am trying to use DECODE function to set values but having trouble finding a way to set only few values and leave others the way they are. Let's say i have a list of state values which is CA, NY, MN, and NV. What I want to do is to decode only CA and NY to California and New York and leave MN and NV as they are. How to do that? Can anyone help? Thanks in advance.

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


WebFOCUS 7.1.6 on Win 2K/IIS 6/ISAPI HTML
January 16, 2009, 06:48 PM
Darin Lee
Use the 'ELSE' at the end of your decode, meaning that if it find the value, it decodes, it ELSE set it to some other value which can be the original field (value).

LONG_STATE/A20=DECODE STATE('CA' 'California' 'NY' 'New York' ELSE STATE);


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
January 16, 2009, 07:04 PM
Learner
Darin,

Thanks for the response.

This is my code. SORT/A20=DECODE &sortField('CA' 'California' 'NY' 'New York' ELSE &sortField);

I am using amper variable within the decode funciton. In my case &sortField can be NA_STATE or STATE. But the report returns only three values, California, New York and NA_STATE OR STATE.

I have actually changed the code to SORT/A20=DECODE NA_STATE('CA' 'California' 'NY' 'New York' ELSE NA_STATE), But i still get the same result... Don't understand why is that?


WebFOCUS 7.1.6 on Win 2K/IIS 6/ISAPI HTML
January 16, 2009, 07:34 PM
Learner
Tom,

Thank you for the solution. It works and I am going to using your suggestion. Thank you.

Learner


WebFOCUS 7.1.6 on Win 2K/IIS 6/ISAPI HTML