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     [SOLVED] FUNCTION AND FORMILA ASSISTANCE

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED] FUNCTION AND FORMILA ASSISTANCE
 Login/Join
 
Member
posted
Good morning,

Im building a financial report in WEBFOCUS 5.3 and trying to create two defined fields using the following function. The formula below works if the "multiply by" is the same.

IF BTL.BT_LINE.A1_LineWeight_ActualUOM EQ 'TD' AND BTL.BT_LINE.Origin_City EQ 'LEMOORE' OR 'YUMA' OR 'SAN DIEGO' OR 'NORFOLK' OR 'VIRGINIA BEACH' OR 'CHERRY POINT' OR 'JACKSONVILLE' OR 'CHINA LAKE' OR 'LEMOORE' OR 'PUGET SOUND' OR 'FALLON' OR 'BREMERTON' THEN BTL.BT_LINE.A1_LineWeight_Actual * 5000 ELSE 0

1. I need change each cities "multiply by" to a different number. Can anyone offer a solution to my issue? How can I change my functions to perform these different calculations in the same defined field? I tried the following but get the error below:

FUNCTION/FORMULA THAT ERROR'D:

IF BTL.BT_LINE.A1_LineWeight_ActualUOM EQ 'TD' AND BTL.BT_LINE.Origin_City EQ 'LEMOORE' THEN BTL.BT_LINE.A1_LineWeight_Actual * 5000 ELSE 0 OR BTL.BT_LINE.Origin_City EQ 'YUMA' THEN BTL.BT_LINE.A1_LineWeight_Actual * 8500 OR
BTL.BT_LINE.Origin_City EQ 'NORFOLK' THEN BTL.BT_LINE.A1_LineWeight_Actual * 10500 ELSE 0

-ERROR CODE:
0 ERROR AT OR NEAR LINE 13 IN PROCEDURE ADHOCRQ FOCEXEC *
(FOC266) IF .. THEN .. ELSE .. SYNTAX ERROR
0 NUMBER OF ERRORS= 0
NUMBER OF SEGMENTS= 1 ( REAL= 1 VIRTUAL= 0 )
NUMBER OF FIELDS= 285 INDEXES= 0 FILES= 1
TOTAL LENGTH OF ALL FIELDS= 6032

2. The second defined field is to identify weight ranges i.e. 1-150, 151-300 etc. How do I change my functions to perform multiple calculations in the same defined field? My initial formula below ran however it populated all the rows with the same results regardless of of the weight.

FUNCTION/FORMULA THAT RAN:
IF BTL.BT_LINE.A1_LineQuantity_BillingUnitsUOM EQ 'LB' AND BTL.BT_LINE.A1_LineQuantity_BillingUnits LE 150 THEN '1-150' ELSE 0

FUNCTION FORMULA THAT ERROR'D: Same error as above.

IF BTL.BT_LINE.A1_LineQuantity_BillingUnitsUOM EQ 'LB' AND BTL.BT_LINE.A1_LineQuantity_BillingUnits LE 150 THEN '1-150' OR BTL.BT_LINE.A1_LineQuantity_BillingUnits GE 151 AND LE 300 THEN '151-300' OR BTL.BT_LINE.A1_LineQuantity_BillingUnits GE 301 AND LE 600 THEN '301-600' ELSE 0

Please help.

Mike

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


WEBFOCUS REPORT ASSISTANT VER 5 RELEASE 3.3
Windows XP
Excel, HTML, PDF
 
Posts: 5 | Registered: December 10, 2009Report This Post
Expert
posted Hide Post
The error message is telling you that your syntax is incorrect. Try something like this:
IF BTL.BT_LINE.A1_LineQuantity_BillingUnitsUOM EQ 'LB' AND BTL.BT_LINE.A1_LineQuantity_BillingUnits LE 150 THEN '1-150' ELSE IF BTL.BT_LINE.A1_LineQuantity_BillingUnits GE 151 AND LE 300 THEN '151-300' ELSE IF BTL.BT_LINE.A1_LineQuantity_BillingUnits GE 301 AND LE 600 THEN '301-600' ELSE 0;

Leave your ELSE 0 to the end and replace your OR's with IF.


Ginny
---------------------------------
Prod: WF 7.7.01 Dev: WF 7.6.9-11
Admin, MRE,self-service; adapters: Teradata, DB2, Oracle, SQL Server, Essbase, ESRI, FlexEnable, Google
 
Posts: 2723 | Location: Ann Arbor, MI | Registered: April 05, 2006Report This Post
Virtuoso
posted Hide Post
You're not constructing your IF-THEN-ELSE logic correctly and throwing some OR's in there where they don't belong. The OR is part of the equivalency test, NOT part of the IF-THEN-ELSE statement.

Your first statement should be
IF BTL.BT_LINE.A1_LineWeight_ActualUOM EQ 'TD' THEN 
  (IF BTL.BT_LINE.Origin_City EQ 'LEMOORE' THEN BTL.BT_LINE.A1_LineWeight_Actual * 5000 ELSE 
   IF BTL.BT_LINE.Origin_City EQ 'YUMA' THEN BTL.BT_LINE.A1_LineWeight_Actual * 8500 ELSE 
   IF BTL.BT_LINE.Origin_City EQ 'NORFOLK' THEN BTL.BT_LINE.A1_LineWeight_Actual * 10500 ELSE 0) 
ELSE 0;


Your second statement has the same issue. Following the same logic as above (and using FROM-TO to simplify it):
IF BTL.BT_LINE.A1_LineQuantity_BillingUnitsUOM EQ 'LB' THEN 
  (IF BTL.BT_LINE.A1_LineQuantity_BillingUnits LE 150 THEN '1-150' ELSE
   IF BTL.BT_LINE.A1_LineQuantity_BillingUnits FROM 151 TO 300 THEN '151-300' ELSE
   IF BTL.BT_LINE.A1_LineQuantity_BillingUnits FROM 301 TO 600 THEN '301-600' ELSE 0)
ELSE 0;


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, 2007Report This Post
Expert
posted Hide Post
Simple rules for IF..THEN..ELSE..

Make it readable
Use () to group logical tests


A suggested replacement for EQ OR OR OR would be IN ()


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

 
Posts: 6347 | Location: 33°49'23.0"S, 151°11'41.0"E | Registered: October 31, 2006Report This Post
Expert
posted Hide Post
LineWeight/D8 =
IF BTL.BT_LINE.A1_LineWeight_ActualUOM EQ 'TD' AND BTL.BT_LINE.Origin_City EQ 'LEMOORE' THEN BTL.BT_LINE.A1_LineWeight_Actual * 5000 ELSE 
IF BTL.BT_LINE.Origin_City EQ 'YUMA' THEN BTL.BT_LINE.A1_LineWeight_Actual * 8500 ELSE
IF BTL.BT_LINE.Origin_City EQ 'NORFOLK' THEN BTL.BT_LINE.A1_LineWeight_Actual * 10500 ELSE 0;


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
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
Member
posted Hide Post
Thanks everyone for the guidance, it works!!! Appreciate all your quick responses.

Happy Holidays to all!

R/Mike


WEBFOCUS REPORT ASSISTANT VER 5 RELEASE 3.3
Windows XP
Excel, HTML, PDF
 
Posts: 5 | Registered: December 10, 2009Report 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     [SOLVED] FUNCTION AND FORMILA ASSISTANCE

Copyright © 1996-2020 Information Builders