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.


Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     Using a Field in a calculation.

Read-Only Read-Only Topic
Go
Search
Notify
Tools
Using a Field in a calculation.
 Login/Join
 
Member
posted
I am wondering if anybody has done this.

Say I have a table SAMPLE with three fields

field1 field2 field3
10 2 /
3 4 *

TABLE FILE SAMPLE
COMPUTE NEWVALUE/D12.2 = ( FIELD1 FIELD3 FIELD2);
END

So the end results would be that field 3 contains what should be done to the numeric fields.

The output would be

10 / 2 = 5
3 * 4 = 12

-Brian


PROD: WF 7.1.3 on Win 2003/IIS 6/Self-Serve & MRE
TEST: We dont need no Stinking Test Server!
 
Posts: 16 | Registered: February 10, 2006Report This Post
Platinum Member
posted Hide Post
This seems to work Brian.....
>> First concatenate the 3 fields in the correct order. This will create an alpha-field with the computation expression.
>> Then assign this field with a .EVAL, to another variable to get the result.

The following example is with a -SET. You shold be able to carry it over to a DEFINE or COMPUTE.
-*-*
-*-*
-SET &ECHO=ALL;
-*
-SET &F1='6';
-SET &F2='/';
-SET &F3='2';
-*
-SET &F4= &F1 || &F2 || &F3 ;
-TYPE &F4 // shows literal 6/2
-SET &F5 = &F4.EVAL;
-TYPE &F5; // shows 3
-EXIT

Thanks for the Q Brian, it got those creative juices rolling. I am positive that the FOCUS gurus around will find a more elegant solution too.

Hope that helps.
Sandeep Mamidenna.

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


-------------------------------------------------------------------------------------------------
Blue Cross & Blue Shield of MS
WF.76-10 on (WS2003 + WebSphere) / EDA on z/OS + DB2 + MS-SQL
MRE, BID, Dev. Studio, Self-Service apps & a dash of fun !! Music
 
Posts: 218 | Location: Jackson, MS | Registered: October 31, 2006Report This Post
Platinum Member
posted Hide Post
Another idea:

DEFINE FILE CAR
CNT/I5 WITH CAR = CNT + 1;
FIELD1/D12.2 WITH CAR = DECODE CNT (
1 5
2 5
3 5
4 5
5 5
);
FIELD2/D12.2 WITH CAR = DECODE CNT (
1 10
2 10
3 10
4 10
5 10
);
FIELD3/A1 WITH CAR = DECODE CNT (
1 '*'
2 '/'
3 '+'
4 '-'
5 '?'
);
END
-*
TABLE FILE CAR
PRINT FIELD1 FIELD2 FIELD3
WHERE RECORDLIMIT EQ 5
ON TABLE HOLD AS TESTFILE FORMAT ALPHA
END
-*
DEFINE FILE TESTFILE
NEWVALUE/D12.2 = IF FIELD3 EQ '*' THEN FIELD1 * FIELD2
ELSE IF FIELD3 EQ '/' THEN FIELD1 / FIELD2
ELSE IF FIELD3 EQ '+' THEN FIELD1 + FIELD2
ELSE IF FIELD3 EQ '-' THEN FIELD1 - FIELD2
ELSE 0.00;
END
-*
TABLE FILE TESTFILE
PRINT FIELD1 FIELD3 FIELD2 NEWVALUE
END
-*

Jim


WF DevStu 5.2.6/WF Srv 5.2.4/Win NT 5.2
 
Posts: 118 | Location: Lincoln Nebraska | Registered: May 04, 2005Report This Post
Member
posted Hide Post
Thanks for the help. I ended up doing it the way Jim recommend as the values I wanted to do the comparison on are in table I was reading.

Thanks for the Help


PROD: WF 7.1.3 on Win 2003/IIS 6/Self-Serve & MRE
TEST: We dont need no Stinking Test Server!
 
Posts: 16 | Registered: February 10, 2006Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     Using a Field in a calculation.

Copyright © 1996-2020 Information Builders