Focal Point
[SOLVED] altering negative percentages

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/2307050876

August 25, 2015, 12:21 PM
CathyB
[SOLVED] altering negative percentages
Hi,

Not sure why I'm struggling with this but I have the following compute:

 COMPUTE DAILY_COMPLLY/P7.1%B =IF  ( DAILY_TY - DAILY_LY ) / DAILY_LY * 100 GT 100.0 THEN 100.0 ELSE IF  ( DAILY_TY - DAILY_LY ) / DAILY_LY * 100 GT -100.0 THEN -100.0  ELSE  ( DAILY_LY_LLY_COMP - DAILY_LLY_COMP ) / DAILY_LLY_COMP * 100; AS ''  


Altering any positive percentages above 100% work fine, displays as 100.0% even if its really (2500.0%) but I can't get it to work with any negative percentage. So I need a -2500.0% to display as -100.0%.

Can someone help me with this. GT or LT does not work. GT display every row of data to -100.0% and LT does nothing at all.

Thanks in advance
Cathy

This message has been edited. Last edited by: <Kathryn Henning>,


WEBFOCUS 7.14
WEBFOCUS.8.04
August 25, 2015, 01:25 PM
John_Edwards
quote:
ELSE IF ( DAILY_TY - DAILY_LY ) / DAILY_LY * 100 GT -100.0


It seems to me that part above should use LT instead of GT. Are you saying you tried that and it didn't work?



August 26, 2015, 08:59 AM
Vivian
Try increasing the size of your defined field to P9 ......


Vivian Perlmutter
Aviter, Inc.


WebFOCUS Keysheet Rel. 8.0.2
(Almost) 1001 Ways to Work with Dates thru Rel. 8.0.2
Focus since 1982
WebFOCUS since the beginning
Vivian@aviter.com

August 26, 2015, 10:10 AM
Shahram
Lets look at your logic this way:

COMPUTE DAILY_COMPLLY/P7.1%B =
option 1) IF ( DAILY_TY - DAILY_LY ) / DAILY_LY * 100 GT 100.0 THEN 100.0 ELSE
option 2) IF ( DAILY_TY - DAILY_LY ) / DAILY_LY * 100 GT -100.0 THEN -100.0 ELSE
option 3) ( DAILY_LY_LLY_COMP - DAILY_LLY_COMP ) / DAILY_LLY_COMP * 100; AS ''

example1 : value = 2500.0% --> this falls under option 1 line so the answer will be 100.0%
example2 : value = 50.0% --> this falls under option 2 line so the answer will be -100.0%
example3 : value = -50.0% --> this falls under option 2 line so the answer will be -100.0%
example4 : value = -2500.0% --> this falls under option 3 line so the answer will be the calculation

I believe John is correct and in option 2 line you need to change 'GT' to 'LT' and the result will be:


COMPUTE DAILY_COMPLLY/P7.1%B =
option 1) IF ( DAILY_TY - DAILY_LY ) / DAILY_LY * 100 GT 100.0 THEN 100.0 ELSE
option 2) IF ( DAILY_TY - DAILY_LY ) / DAILY_LY * 100 LT -100.0 THEN -100.0 ELSE
option 3) ( DAILY_LY_LLY_COMP - DAILY_LLY_COMP ) / DAILY_LLY_COMP * 100; AS ''

example1 : value = 2500.0% --> this falls under option 1 line so the answer will be 100.0%
example2 : value = 50.0% --> this falls under option 3 line so the answer will be the calculation
example3 : value = -50.0% --> this falls under option 3 line so the answer will be the calculation
example4 : value = -2500.0% --> this falls under option 2 line so the answer will be -100.0%


All Releases
All OS, All Outputs
August 29, 2015, 07:36 AM
CathyB
Thank you all for the input the LT did work. Thought I had tried it and was getting incorrect results. But its working now.

Again, thanks for all your help.


WEBFOCUS 7.14
WEBFOCUS.8.04