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. Moving forward, myibi is our community platform to learn, share, and collaborate. We have the same Focal Point forum categories in myibi, so you can continue to have all new conversations there. If you need access to myibi, contact us at myibi@ibi.com and provide your corporate email address, company, and name. Connect to myibi
Focal Point    Focal Point Forums    WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] FORMULA USING FTOA AND ALPHANMUMERIC FIELDS

Read-Only Topic
 Go Search Notify Tools
 [SOLVED] FORMULA USING FTOA AND ALPHANMUMERIC FIELDS
Platinum Member
 posted August 21, 2020 03:42 PM
Everyone,

I am near the end of a project. I have two final components to solve. I am hoping someone on the forum might have an idea as to how to solve on of them.

Here is my question: I have a rolling five years of data. My users select the last year and then they get to see that year, plus the previous five years.

At the end, we want to calculate two percentages of change.

The first one (PCTCHG1F) is basically the last year minus the previous year. If either field is 0, then it is masked and the formula provides a dash. Otherwise, the calculated percentage (from an earlier table) displays nicely.

That formula works beautifully.

The second formula (PCTCHG5F) does not work as well. It should be the current year minus the first year. If either the values of the first year and last year result in zeroes, they are masking appropriately with the caret. However, if the first year has a value but the last year is masked with a caret, the formula should behave just like the first formula and result in a dash. It's not.

I've tried using FST.

Is there a better way to do this? As an aside, I separated the COMPUTE statements below for ease in reading.

[CODE] TABLE FILE JDATA
PRINT
COUNTS3
PCTCHG1
PCTCHG5
SORT_GROUP2
SORT_GROUP
SORT_CATEGORY
CATEGORY
YR

COMPUTE ALPHAC/A15=FTOA(COUNTS3,'(D11)','A15');
COMPUTE ALPHAC_F/A15 =IF COUNTS3 EQ '0' THEN '^' ELSE ALPHAC;

-*Note the LAST takes into account the value for the max year less one. In other words, it returns the previous year's data correctly.

COMPUTE PCTCHG1ALPHA/A15=FTOA(PCTCHG1,'(D11.1%)','A15');
COMPUTE PCTCHG1F/A15 =IF LAST ALPHAC_F EQ '^' THEN '-' ELSE IF ALPHAC_F EQ '^' THEN '-' ELSE PCTCHG1ALPHA;

-*Is there a better way to account for the first instance of ALPHA_C_F? I am getting a value of 0% when the first value is masked. I want a dash when either the first year or last year is masked. I only want percentages when both have values.

COMPUTE PCTCHG5ALPHA/A15=FTOA(PCTCHG5,'(D11.1%)','A15');
COMPUTE PCTCHG5F/A15 =IF FST.ALPHAC_F EQ '^' THEN '-' ELSE IF ALPHAC_F EQ '^' THEN '-' ELSE PCTCHG5ALPHA;

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

WebFocus 8.2.04
WebFocus 8.2.04

 Posts: 191 | Registered: September 18, 2015 IP
Guru
 posted August 24, 2020 02:24 AM Hide Post
FST only works in SUM, you could work around this by splitting data in a DEFINE e.g. IF YEAR EQ &firstYear THEN VALUE ELSE MISSING;

Test: WF 8.2
Prod: WF 8.2
DB: Progress, REST, IBM UniVerse/UniData, SQLServer, MySQL, PostgreSQL, Oracle, Greenplum, Athena.

 Posts: 454 | Location: Europe | Registered: February 05, 2007 IP
Virtuoso
 posted August 24, 2020 08:32 AM Hide Post
An option is also not to try to do all in one step.

First, create the data as you need but with real numbers. Even if you have too many columns and non desired one, it's not important since it's an temp-step.
Second, use step one result to then add the masking option and only keep desired columns.

Often, trying to do all in one step make it more confusing and difficult to accomplish.

WF versions : Prod 8.2.04M gen 33, Dev 8.2.04M gen 33, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007

 Posts: 2410 | Location: Montreal Area, Qc, CA | Registered: September 25, 2013 IP
Platinum Member
 posted August 24, 2020 03:35 PM Hide Post
Thank you both.

As to the suggestions: In the end, my solution utilized a missing component higher up in my procedure and then I continued it down below in the section I was asking about.

Again, thank you both. Something each of you said made the light bulb go off in my head

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

WebFocus 8.2.04
WebFocus 8.2.04

 Posts: 191 | Registered: September 18, 2015 IP
 Powered by Social Strata

Read-Only Topic

Focal Point    Focal Point Forums    WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] FORMULA USING FTOA AND ALPHANMUMERIC FIELDS

Copyright © 1996-2020 Information Builders