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.
I am having trouble getting this IF ELSE statement to work. For some reason it does not get to the last IF that should return a 5, but when I have that IF statemetn seperate it works fine.
MROS_PLAN = IF ((CURRENT_ACTUAL_TP3 - CURRENT_PLAN_TP3)/(CURRENT_ACTUAL_TP8A - CURRENT_PLAN_TP8A)) GT 0 AND (CURRENT_ACTUAL_TP3 - CURRENT_PLAN_TP3) LT 0 THEN (CURRENT_ACTUAL_TP3 - CURRENT_PLAN_TP3)* -1 ELSE IF ((CURRENT_ACTUAL_TP3 - CURRENT_PLAN_TP3)/(CURRENT_ACTUAL_TP8A - CURRENT_PLAN_TP8A)) GT 0 AND (CURRENT_ACTUAL_TP3 - CURRENT_PLAN_TP3) GT 0 THEN (CURRENT_ACTUAL_TP3 - CURRENT_PLAN_TP3) ELSE
IF ((CURRENT_ACTUAL_TP3 - CURRENT_PLAN_TP3)/(CURRENT_ACTUAL_TP8A - CURRENT_PLAN_TP8A)) LT 0 AND (CURRENT_ACTUAL_TP3 - CURRENT_PLAN_TP3) LT 0 THEN 5;
THIS ONE WORKS
MROS_PLAN = IF ((CURRENT_ACTUAL_TP3 - CURRENT_PLAN_TP3)/(CURRENT_ACTUAL_TP8A - CURRENT_PLAN_TP8A)) LT 0 AND (CURRENT_ACTUAL_TP3 - CURRENT_PLAN_TP3) LT 0 THEN 5;
This message has been edited. Last edited by: Kerry,
WebFOCUS 7.6.9 Windows all output (Excel, PDF, HTML)
Prarie's suggestion of adding a final ELSE is very valid. IF..THEN..ELSE logic should always have a final ELSE in case none of the IF criteria are satisfied. Also, you could try adding some parathensis and switching around your calculation with -1.
MROS_PLAN = IF (((CURRENT_ACTUAL_TP3 - CURRENT_PLAN_TP3)/(CURRENT_ACTUAL_TP8A - CURRENT_PLAN_TP8A)) GT 0 AND
(CURRENT_ACTUAL_TP3 - CURRENT_PLAN_TP3) LT 0)
THEN (-1 * (CURRENT_ACTUAL_TP3 - CURRENT_PLAN_TP3))
ELSE IF (((CURRENT_ACTUAL_TP3 - CURRENT_PLAN_TP3)/(CURRENT_ACTUAL_TP8A - CURRENT_PLAN_TP8A)) GT 0 AND
(CURRENT_ACTUAL_TP3 - CURRENT_PLAN_TP3) GT 0)
THEN (CURRENT_ACTUAL_TP3 - CURRENT_PLAN_TP3)
ELSE IF (((CURRENT_ACTUAL_TP3 - CURRENT_PLAN_TP3)/(CURRENT_ACTUAL_TP8A - CURRENT_PLAN_TP8A)) LT 0 AND
(CURRENT_ACTUAL_TP3 - CURRENT_PLAN_TP3) LT 0)
THEN 5
ELSE ? ;
WebFOCUS 7.7.05
Posts: 1213 | Location: Seattle, Washington - USA | Registered: October 22, 2007
Please consider the following code where I created your CURRENT* fields (total bogus I might add) then simplified your IF...Then...ELSE. And, OBTW, I did add the ELSE at the end which really is not "required" other then as a "best practice technique".
DEFINE FILE CAR
CURRENT_ACTUAL_TP3 = MPG + HEIGHT;
CURRENT_PLAN_TP3 = HEIGHT ;
CURRENT_ACTUAL_TP8A = WIDTH ;
CURRENT_PLAN_TP8A = WIDTH * .95 ;
CALC1/D12.2 = CURRENT_ACTUAL_TP3 - CURRENT_PLAN_TP3 ;
CALC2/D12.2 = CURRENT_ACTUAL_TP8A - CURRENT_PLAN_TP8A ;
MROS_PLAN = IF ((CALC1)/(CALC2)) GT 0 AND (CALC1) LT 0 THEN -CALC1
ELSE IF ((CALC1)/(CALC2)) GT 0 AND (CALC1) GT 0 THEN CALC1
ELSE IF ((CALC1)/(CALC2)) LT 0 AND (CALC1) LT 0 THEN 5
ELSE 0;
END
TABLE FILE CAR
PRINT CALC1 CALC2 MROS_PLAN
BY MODEL
END
It seems that the source of the error is "(CURRENT_ACTUAL_TP3 - CURRENT_PLAN_TP3)* -1" more then anything else.
I would like you to, also, consider a more structured approach to your coding which would make it easier to analyze and maintain for those who follow (Who knows, It may be one of us).
In FOCUS Since 1983 ~ from FOCUS to WebFOCUS. Current: WebFOCUS Administrator at FIS Worldpay | 8204, 8206
Posts: 3132 | Location: Tennessee, Nashville area | Registered: February 23, 2005
This will give you error. Without ELSE phrase, when none of the conditions were true, then WebFOCUS will take the previous true conditions value.
TABLE FILE CAR
SUM
DEALER_COST
BY COUNTRY
BY CAR
ON TABLE HOLD AS HLD FORMAT ALPHA
END
DEFINE FILE HLD
CC_DEF/A20=IF COUNTRY EQ 'ENGLAND' THEN 'value1' ELSE IF COUNTRY EQ 'FRANCE' THEN 'value2';
END
TABLE FILE HLD
PRINT
CAR
CC_DEF
COMPUTE CC_COMP/A20=IF COUNTRY EQ 'ENGLAND' THEN 'value1' ELSE IF COUNTRY EQ 'FRANCE' THEN 'value2';
BY COUNTRY
END