Focal Point Banner


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.



Read-Only Read-Only Topic
Go
Search
Notify
Tools
COMPUTE
 Login/Join
 
Gold member
posted
Iam kind of newbie to Webfocus. Iam trying to accompllish a task, but couldn't find a way.

Scenario:-

ID|P% | Atv -- these are fields
Case i:-
Tomy 100 2
Tomy 0 2
Tomy 0 3
Tomy 0 4
Case 2:-
Tomy 0 1
Tomy 0 2
Tomy 0 3
Tomy 0 4
Case 3:-
Tomy 100 2
Tomy 100 3
Tomy 100 4
Tomy 0 5

I want to define a field and this field should contain values like

ID|P% | ATV | COMP -- these are fields
Case i data:- COMP is 2 becoz P% has 100 and related ATV value
v100 100 2 2
v100 0 2 2
v100 0 3 2
v100 0 4 2
Case 2 data:- COMP is 1 becoz P% has 0 and related lowest ATV value
v101 0 1 1
v101 0 2 1
v101 0 3 1
v101 0 4 1
Case 3 data:- COMP is 4 becoz highest ATV where P% is 100.
v102 100 2 4
v102 100 3 4
v102 100 4 4
v102 0 5 4

New field COMP should have
Highest "Atv" value where p% is 100
or
Lowest "Atv" value where p% is 0 if entire ID is 0's.


If possible could you send me a sample code for Compute Statement.

Thank you guys
 
Posts: 82 | Location: Chicago | Registered: September 28, 2005Report This Post
Virtuoso
posted Hide Post
Does your data have the case number tied to each line of information? Computes are performed at the aggregate(or for each record) after a sort or if no sort then for each record. Might be you need to do some creative selection with a where total, put in a hold file and then do the COMP. Or COMPUTE a COMP for each line then do some other selection.
I see this as a multiple step process.
 
Posts: 1317 | Location: Council Bluffs, IA | Registered: May 24, 2004Report This Post
Gold member
posted Hide Post
Thanks leah

The case#'s i mentioned are not the part of the data, Data is stright 12 rows.

Case # actually indicate the different scenarios in my data.

Tomy 100 2 == v100 100 2 2

Type error -- Tomy is equal to v100, both the fields are alphanumeric.


any suggestions are appreciated
 
Posts: 82 | Location: Chicago | Registered: September 28, 2005Report This Post
Virtuoso
posted Hide Post
Okay, had a few moments to play and here is what I came up with ( not pretty may not be even what you want ):

-SET &ECHO=ALL;
SET ASNAMES = ON
FILEDEF LRECL80_UNO DISK D:\FOCUS\UNO\QUALOUT\TEST.TXT
DEFINE FILE LRECL80_UNO
COUNTER/I2 = IF COUNTER EQ 4 THEN 1 ELSE COUNTER + 1;
KEY/I2 = IF COUNTER EQ 1 THEN KEY + 1 ELSE KEY;
CASE/A4 = EDIT (LINE80,'9999');
PCT/A4 = EDIT (LINE80,'$$$$$999');
PCTN/I4 = EDIT (PCT);
ATV/A1 = EDIT(LINE80,'$$$$$$$$$9');
ATVN/I1 = EDIT(ATV);
END
-* DEFINES NOT NEEDED IF YOU HAVE MFD
-* LRECL80_UNO IS JUST A FAKE OUT TO DO 80 COLUMN RECORDS HAVE TO DEFINE THE FIELDS IN
-* THE PROGRAM
-* CREATE SOME FIELDS TO HELP
TABLE FILE LRECL80_UNO
PRINT CASE PCTN ATVN
COMPUTE HAS100/I1 = IF PCTN EQ 100 THEN 1 ELSE 0;
COMPUTE AVX/I1 = ATVN;
BY KEY
BY PCTN
BY ATVN
ON TABLE HOLD AS HOLD1
END
-* RESORT AND PULL FIRST AND LAST CALCULATED IN PREVIOUS JOB AS IT DOES LOW TO HIGH
-* NOW SORT HIGH TO LOW
TABLE FILE HOLD1
SUM HAS100 FST.AVX AS FAVX LST.AVX AS LAVX
BY KEY
PRINT CASE PCTN ATVN AVX
BY KEY
BY HIGHEST PCTN
BY HIGHEST ATVN
ON TABLE HOLD AS HOLD2
END
-*NOW PUT THE COMP ON EACH CASE LINE
TABLE FILE HOLD2
PRINT KEY CASE PCTN ATVN HAS100
COMPUTE COMP/I1 = IF HAS100 EQ 0 THEN FAVX ELSE LAVX;
ON TABLE HOLD AS HOLD3
END
-* NOW IF YOU ONLY WANT THE LINE OF THE CASE THAT APPLIES
TABLE FILE HOLD3
PRINT KEY CASE PCTN ATVN COMP
COMPUTE WANTED/I1 = IF HAS100 GT 0 AND COMP EQ ATVN AND PCTN NE 0 THEN 1
ELSE IF HAS100 EQ 0 AND PCTN EQ 0 AND COMP EQ ATVN THEN 1 ELSE 0; NOPRINT
WHERE TOTAL WANTED EQ 1
END

Gives this

PAGE 1

KEY CASE PCTN ATVN COMP
1 TOMY 100 2 2
2 TOMY 0 1 1
3 TOMY 100 4 4
 
Posts: 1317 | Location: Council Bluffs, IA | Registered: May 24, 2004Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic


Copyright © 1996-2020 Information Builders