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] Difference between two rows of data

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED] Difference between two rows of data
 Login/Join
 
Gold member
posted
 $K	Year	Apr-09	May-09 Jun-09	Jul-09	Aug-09	Sep-09	Oct-09	Nov-09	Dec-09	Jan-10	Feb-10	Mar-10	Total
Shipment  2009	424	559	560	537	451	606	588	392	0	0	0	0	4,116
	2008	741	764	818	758	776	833	682	794	516	506	497	597	8,281
YOY		-317	-205	-258										
 


Is there a way to calculate difference between two rows ?

Thank you.
KK

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


Test - Webfocus 7.6.7
Prod - Webfocus 7.6.7
Win2003
Sql Server 2000 and 2008
 
Posts: 59 | Registered: May 01, 2007Report This Post
Platinum Member
posted Hide Post
Hi KK,

You can use the LAST command.

Best Regards,

Jimmy Pang


DEV: WF 7.6.10
TEST: WF 7.6.10
PROD: WF 7.6.10
MRE: WF 7.6.4
OS/Platform: Windows
Dev Studio: WF 7.7
Output: HTML, EXCEL, PDF, GRAPH, LOTUS, CSV
 
Posts: 117 | Location: Toronto, Ontario, Canada | Registered: February 29, 2008Report This Post
Expert
posted Hide Post
That's the best bang for the buck: The LAST Command.
 
Posts: 3132 | Location: Tennessee, Nashville area | Registered: February 23, 2005Report This Post
Platinum Member
posted Hide Post
Here's a simple code used in a COMPUTE as an example:

  
TABLE FILE CAR
SUM
     SALES
     COMPUTE DIFF/D12.2 = LAST SALE - SALE;
BY COUNTRY
END


Best Regards,

Jimmy Pang


DEV: WF 7.6.10
TEST: WF 7.6.10
PROD: WF 7.6.10
MRE: WF 7.6.4
OS/Platform: Windows
Dev Studio: WF 7.7
Output: HTML, EXCEL, PDF, GRAPH, LOTUS, CSV
 
Posts: 117 | Location: Toronto, Ontario, Canada | Registered: February 29, 2008Report This Post
Gold member
posted Hide Post
Hi,

I am not sure if that would work for

TABLE FILE NEO_SHIPMENT_DATA
SUM
COMPUTE B1/F8C = MONTH1 / 1000; AS '&M1'
COMPUTE B2/F8C = MONTH2 / 1000; AS '&M2'
COMPUTE B3/F8C = MONTH3 / 1000; AS '&M3'
COMPUTE B4/F8C = MONTH4 / 1000; AS '&M4'
COMPUTE B5/F8C = MONTH5 / 1000; AS '&M5'
COMPUTE B6/F8C = MONTH6 / 1000; AS '&M6'
COMPUTE B7/F8C = MONTH7 / 1000; AS '&M7'
COMPUTE B8/F8C = MONTH8 / 1000; AS '&M8'
COMPUTE B9/F8C = MONTH9 / 1000; AS '&M9'
COMPUTE B10/F8C = MONTH10 / 1000; AS '&M10'
COMPUTE B11/F8C = MONTH11 / 1000; AS '&M11'
COMPUTE B12/F8C = MONTH12 / 1000; AS '&M12'
COMPUTE ROWTOTAL/F8C = B1 + B2 + B3 + B4 + B5 + B6 + B7 + B8 + B9 + B10 + B11 + B12;


AS 'Total'
BY K AS '$K'
BY HIGHEST CALENDAR_FISCAL_YEAR AS 'Year'
ON TABLE PCHOLD FORMAT EXL2K
END

where M1, M2 so on are the 12 fiscal months starting April, May..

Please advise.

Thank you.
KK


Test - Webfocus 7.6.7
Prod - Webfocus 7.6.7
Win2003
Sql Server 2000 and 2008
 
Posts: 59 | Registered: May 01, 2007Report This Post
Silver Member
posted Hide Post
KK, You may need to do this in 2 pass, i.e hold summarized data in a file and then do a table file on that hold file like the example below.
The answer lies in the "LAST" command but I notice since you need the column difference in a third row you would need to use the subfoot to get the difference as a row.


TABLE FILE CAR
SUM RETAIL_COST
DEALER_COST
COMPUTE DIFF1/P10.2C = RETAIL_COST - LAST RETAIL_COST ; NOPRINT
COMPUTE DIFF2/P10.2C = DEALER_COST - LAST DEALER_COST ; NOPRINT
BY COUNTRY
WHERE COUNTRY EQ 'ENGLAND' OR 'FRANCE'
ON TABLE SUBFOOT
"DIFFERENCE:<+0>-*ON TABLE PCHOLD FORMAT EXL2K
ON TABLE SET STYLE *
TYPE=REPORT, SIZE=9,FONT='ARIAL',HEADALIGN=BODY,$
TYPE=TABFOOTING,ITEM=1,JUSTIFY=LEFT,$
TYPE=TABFOOTING,ITEM=2,JUSTIFY=RIGHT,$
TYPE=TABFOOTING,ITEM=3,JUSTIFY=RIGHT,$
ENDSTYLE
END
-RUN


-Yogesh Patel
------------------------------------------------------------------------
PROD: WF 764 on Linux Apache tomcat v5.5
DEV: WF 768 on Linux
 
Posts: 42 | Location: Edison, New Jersey | Registered: January 30, 2007Report This Post
Guru
posted Hide Post
KK, depends on how you structure your data. If you only have 2 years of monthly shipments per record, you can try this:
TABLE FILE CAR
SUM
SALES AS 'This Year' OVER
DCOST AS 'Last Year' OVER 
COMPUTE PROFIT/D12 = SALES - DCOST; AS 'Diff'
BY COUNTRY
ACROSS CAR
WHERE COUNTRY EQ 'ENGLAND'
ON TABLE ROW-TOTAL
END
  



Hua


Developer Studio 7.6.11
AS400 - V5R4
HTML,PDF,XLS
 
Posts: 305 | Location: Winnipeg,MB | Registered: May 12, 2008Report This Post
Virtuoso
posted Hide Post
Or you can take a look at Financial Modeling Language (FML)
it gives you a lot of other ways to create a report




Frank

prod: WF 7.6.10 platform Windows,
databases: msSQL2000, msSQL2005, RMS, Oracle, Sybase,IE7
test: WF 7.6.10 on the same platform and databases,IE7

 
Posts: 2387 | Location: Amsterdam, the Netherlands | Registered: December 03, 2006Report This Post
Virtuoso
posted Hide Post
Taking ideas from earlier posts (use of LAST and SUBFOOT), here is one possible solution. If your data source contains only two years of data, then your BY HIGHEST clause will work. But if your data contains more than two years data, then you will need to change it to
BY HIGHEST 2 YEAR AS 'Year'
if you want to limit the report to the latest two years only. I added a third year to the test data so you could see how this report would work for multiple years.

The first SUM verb retrieves the latest year, which is used to prevent a YOY subfoot row from being generated for the first year in the report (WHEN YEAR LT C1; ).

APP FILEDEF SHIPMAS DISK shipdata.mas
-RUN
-WRITE SHIPMAS FILENAME=SHIPDATA,SUFFIX=FIX
-WRITE SHIPMAS SEGNAME=SHIPDATA,SEGTYPE=S0
-WRITE SHIPMAS FIELDNAME=K       ,ALIAS=K       ,FORMAT=A10,ACTUAL=A10,$
-WRITE SHIPMAS FIELDNAME=YEAR    ,ALIAS=YEAR    ,FORMAT=YY ,ACTUAL=A4 ,$
-REPEAT :ENDREPEAT1 FOR &I FROM 1 TO 12
-WRITE SHIPMAS FIELDNAME=MONTH&I ,ALIAS=MONTH&I ,FORMAT=D8 ,ACTUAL=A7 ,$
-:ENDREPEAT1
-*
APP FI SHIPDATA DISK shipdata.ftm
-RUN
-WRITE SHIPDATA Shipment  2007 999000 888000 777000 666000 555000 444000 333000 222000 111000 987000 654000 321000
-WRITE SHIPDATA Shipment  2008 741000 764000 818000 758000 776000 833000 682000 794000 516000 506000 497000 597000
-WRITE SHIPDATA Shipment  2009 424000 559000 560000 537000 451000 606000 588000 392000      0      0      0      0
-RUN
-SET &M1 = 'Apr-09';
-SET &M2 = 'May-09';
-SET &M3 = 'Jun-09';
-SET &M4 = 'Jul-09';
-SET &M5 = 'Aug-09';
-SET &M6 = 'Sep-09';
-SET &M7 = 'Oct-09';
-SET &M8 = 'Nov-09';
-SET &M9 = 'Dec-09';
-SET &M10 = 'Jan-10';
-SET &M11 = 'Feb-10';
-SET &M12 = 'Mar-10';
-*
TABLE FILE SHIPDATA
  SUM MAX.YEAR NOPRINT
  SUM
-REPEAT :ENDREPEAT2 FOR &I FROM 1 TO 12
  COMPUTE B&I/F8C = MONTH&I / 1000 ; AS '&M.&I'
  COMPUTE DIFFMTH&I/F8C = LAST B&I - B&I ; NOPRINT
-:ENDREPEAT2
  COMPUTE ROWTOTAL/F8C = B1 + B2 + B3 + B4 + B5 + B6 + B7 + B8 + B9 + B10 + B11 + B12; AS 'Total'
  COMPUTE TOTDIFF/F8C  = LAST ROWTOTAL - ROWTOTAL ; NOPRINT
  BY K AS '$K'
  BY HIGHEST YEAR AS 'Year'
  ON YEAR SUBFOOT
     "YOY<+0> <DIFFMTH1<DIFFMTH2<DIFFMTH3<DIFFMTH4<DIFFMTH5<DIFFMTH6<DIFFMTH7<DIFFMTH8<DIFFMTH9<DIFFMTH10<DIFFMTH11<DIFFMTH12<TOTDIFF"
     " "
     WHEN YEAR LT C1 ;
   ON TABLE NOTOTAL
   ON TABLE SET HTMLCSS ON
   ON TABLE PCHOLD FORMAT EXL2K
   ON TABLE SET STYLESHEET *
      TYPE=SUBHEAD, HEADALIGN=BODY, $
      TYPE=SUBFOOT, HEADALIGN=BODY, $
      TYPE=SUBFOOT, OBJECT=FIELD, JUSTIFY=RIGHT, $
   ENDSTYLE
END

This message has been edited. Last edited by: Dan Satchell,


WebFOCUS 7.7.05
 
Posts: 1213 | Location: Seattle, Washington - USA | Registered: October 22, 2007Report This Post
Expert
posted Hide Post
Simplest and most efficient/effective method is, imho and as Frank suggests, to use FML amd use RECAP to get your YOY values.

T

This message has been edited. Last edited by: Tony A,



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
 
Posts: 5694 | Location: United Kingdom | Registered: April 08, 2004Report This Post
Virtuoso
posted Hide Post
KK,

Two questions:
1. For each K, how many CALENDAR_FISCAL_YEAR do you have? Only 2?
2. Do you have 1 K or many?


Daniel
In Focus since 1982
wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF

 
Posts: 1980 | Location: Tel Aviv, Israel | Registered: March 23, 2006Report This Post
Gold member
posted Hide Post
Thank you all for your valuable suggestions.

 Two questions:
1. For each K, how many CALENDAR_FISCAL_YEAR do you have? Only 2?
2. Do you have 1 K or many?
 


1. 2 years. only 2.
2. 1 K column.

Dan Satchell's suggestion looks appropriate to the way the data is structured. But I would also like to consider FML as another approach.

Thank you,
KK


Test - Webfocus 7.6.7
Prod - Webfocus 7.6.7
Win2003
Sql Server 2000 and 2008
 
Posts: 59 | Registered: May 01, 2007Report This Post
Gold member
posted Hide Post
Dan Satchell's solution works great. Thank you Dan !!.


Test - Webfocus 7.6.7
Prod - Webfocus 7.6.7
Win2003
Sql Server 2000 and 2008
 
Posts: 59 | Registered: May 01, 2007Report This Post
Virtuoso
posted Hide Post
KK - you are welcome.


WebFOCUS 7.7.05
 
Posts: 1213 | Location: Seattle, Washington - USA | Registered: October 22, 2007Report 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] Difference between two rows of data

Copyright © 1996-2020 Information Builders