

Go  New  Search  Notify  Tools  Reply 
Platinum Member 
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 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  

Guru 
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.  

Virtuoso 
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 tempstep. 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  

Platinum Member 
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 headThis message has been edited. Last edited by: JulieA, WebFocus 8.2.04 WebFocus 8.2.04  

Powered by Social Strata 
Please Wait. Your request is being processed... 