As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.
Join the TIBCO Community TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.
From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
Request access to the private WebFOCUS User Group (login required) to network with fellow members.
Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.
We have a user in HR that is trying to write their own report (using the same setup listed in my signature) regarding employees and education levels.
The problem they are having is that if a person has two levels of education on record (High School, Bachelors, Masters, or Doctorate) there are two records returned for that user in the report showing identical information for all fields except Education Level.
The desired result is to have only one record per person returned, and to have that record reflect their highest level of education.
I don't have access to the actual tables used in their report due to their sensitive nature, so I tried working the scenario with manufacturing data. My first inclination was to use a DECODE function to assign a value to each education level, and then subject those values to a MAX function to only return the maximum value for each record.
Unfortunately, this approach applies the MAX function to the entire report, not on a by-record basis, and thus only returns those records that reflect the maximum DECODE value...or in the case of Education level, would only return those employees with their Doctorate degree.
Are the DECODE and MAX functions the best way to go about this? If so, how do I apply them to this report on a record-by-record basis? If they are not the best approach, what is...an IF THEN ELSE statement?
For reference, here is the relevant part of the code I used to apply my DECODE and MAX functions:
-* File Define_Test.fex
DEFINE FILE IFS_PART_CATALOG ADD
DESCRIPTION_NUMBERS/I5=DECODE IFS_PART_CATALOG.IFS_PART_CATALOG.DESCRIPTION( 'TRANSDUCER, PRESS' 1 'CIRCUIT BREAKER, SINGLE' 2 'CONNECTOR, RCPT' 3 );
END
TABLE FILE IFS_PART_CATALOG
PRINT
'IFS_PART_CATALOG.IFS_PART_CATALOG.STD_NAME_ID'
'IFS_PART_CATALOG.IFS_PART_CATALOG.DESCRIPTION_NUMBERS' NOPRINT
'IFS_PART_CATALOG.IFS_PART_CATALOG.UNIT_CODE'
'IFS_PART_CATALOG.IFS_PART_CATALOG.CELL_STOCK'
BY 'IFS_PART_CATALOG.IFS_PART_CATALOG.PART_NO'
BY 'IFS_PART_CATALOG.IFS_PART_CATALOG.DESCRIPTION'
HEADING
""
FOOTING
""
WHERE IFS_PART_CATALOG.IFS_PART_CATALOG.DESCRIPTION_NUMBERS EQ MAX(0, 3);
WHERE RECORDLIMIT EQ 50
ON TABLE SET PAGE-NUM OFF
ON TABLE NOTOTAL
ON TABLE PCHOLD FORMAT HTML
ON TABLE SET HTMLCSS ON
ON TABLE SET STYLE *
UNITS=IN,
SQUEEZE=ON,
ORIENTATION=PORTRAIT,
My apologies for the long post, and I thank you in advance for any assistance you may provide.
Evan
WebFOCUS (DEV and PROD): DevStudio 7.6.10 HF2 Servlet - MRE/Dashboard/Self Service/Report Caster - MS Windows XP SP2 - IIS & Apache - MS SQL 2005 Output: HTML (Internet Explorer 7), Excel 2003, PDF, Active Reports and FLEX
Posts: 38 | Location: Detroit, MI | Registered: September 23, 2008
This returns all the levels of education from SQL Server, then WebFOCUS takes over to output the highest level.This message has been edited. Last edited by: Francis Mariani,
Francis
Give me code, or give me retirement. In FOCUS since 1991
Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
to get the highest level for each employee. Otherwise you get the highest level of education available with all employees that have that level.
Also, as Jack states, you would still get two records for someone that has two BA's, two MA's or (eek!) two PhD's (assuming that a Master's of Accounting is the same decode value as an MBA and the like.)
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, 2007
Originally posted by Francis Mariani: The DECODE is fine, but I would use
BY HIGHEST 1 level_of_education
This returns all the levels of education from SQL Server, then WebFOCUS takes over to output the highest level.
My apologies, but I am very new to WebFOCUS, as I'm sure you're aware by this post and my ignorance of the BY HIGHEST 1 command. At risk of sounding like I want you to 'hold my hand', could I ask where in the fex file the 'BY HIGHEST 1' code should appear? Your post makes me think it belongs at the top of the file before the DECODE appears...is this correct?
Something like this for my manufacturing example, perhaps?
sleepyThis message has been edited. Last edited by: sleepyEDB,
WebFOCUS (DEV and PROD): DevStudio 7.6.10 HF2 Servlet - MRE/Dashboard/Self Service/Report Caster - MS Windows XP SP2 - IIS & Apache - MS SQL 2005 Output: HTML (Internet Explorer 7), Excel 2003, PDF, Active Reports and FLEX
Posts: 38 | Location: Detroit, MI | Registered: September 23, 2008
We're all sleepy on Friday afternoon. The BY HIGHEST is an alternate form of the BY command and belongs with the other BYs in your TABLE part. The normal sort order is low to high. BY HIGHEST sorts high to low.
You might want to check the syntax for BY in the language manual, wfcrlang.pdf.
Wow, I guess it's time for me to sign off for the week, eh? It's a BY statement so you think I'd have at least figured out that it goes with the other BY statements.
I have a copy of the wfcrlang, but didn't even think to check it before asking here for help...sorry! :-\
Thanks Ginny, I'll see what I can find and post back if I can't figure it out AFTER reading and experimenting.
sleepy
WebFOCUS (DEV and PROD): DevStudio 7.6.10 HF2 Servlet - MRE/Dashboard/Self Service/Report Caster - MS Windows XP SP2 - IIS & Apache - MS SQL 2005 Output: HTML (Internet Explorer 7), Excel 2003, PDF, Active Reports and FLEX
Posts: 38 | Location: Detroit, MI | Registered: September 23, 2008
I think you are on the right track with assigning a numeric value to the level of education. It shouldn't matter if you use decode or if, then, else. The problem is coming up with one record per employee. Try running through your data two times. In the first pass define the level of education as a numeric value and sort: BY EMPLOYEE BY HIGHEST EDUCATION etc.
In your second pass use: WHERE EMPLOYEE NE LAST EMPLOYEE
Pat WF 7.6.8, AIX, AS400, NT AS400 FOCUS, AIX FOCUS, Oracle, DB2, JDE, Lotus Notes
Posts: 755 | Location: TX | Registered: September 25, 2007