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] CALCULATE "SUBHEAD" FIELD

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED] CALCULATE "SUBHEAD" FIELD
 Login/Join
 
<José Andrés Vargas Aguilar>
posted
Hy, I have a report which data source is the union of two queries with different date.

On this report I display some amounts. Now I need to show also the difference between them.

Something like this is what I have:

ACROSS FIELD
TYPE 1 TYPE 2 TYPE 3 ...
BY1 DATE1 AMOUNT1 AMOUNT2 AMOUNT3 ...
DATE2 AMOUNT1 AMOUNT2 AMOUNT3 ...
BY2 DATE1 AMOUNT1 AMOUNT2 AMOUNT3 ...
DATE2 AMOUNT1 AMOUNT2 AMOUNT3 ...
. . . . . ...
. . . . . ...
. . . . . ...


And I need something like this:

ACROSS FIELD
TYPE 1 TYPE 2 TYPE 3 ...
BY1 DATE1 AMOUNT1 AMOUNT2 AMOUNT3 ...
DATE2 AMOUNT1 AMOUNT2 AMOUNT3 ...
Difference: And here I'd display the difference of the two above values.
BY2 DATE1 AMOUNT1 AMOUNT2 AMOUNT3 ...
DATE2 AMOUNT1 AMOUNT2 AMOUNT3 ...
Difference: And here I'd display the difference of the two above values.
. . . . . ...
. . . . . ...
. . . . . ...

Any help, greatly appreciated.

This message has been edited. Last edited by: <José Andrés Vargas Aguilar>,
 
Report This Post
Platinum Member
posted Hide Post
Use RECAP to do the calculation and SUBFOOT to display the values.
 
Posts: 140 | Location: Adelaide South Australia | Registered: October 27, 2006Report This Post
<José Andrés Vargas Aguilar>
posted
Thanks, can you give me an example?
 
Report This Post
Virtuoso
posted Hide Post
Search the forum for RECAP. I'm confident you'll find plenty of examples.



Prod/Dev: WF Server 8008/Win 2008 - WF Client 8008/Win 2008 - Dev. Studio: 8008/Windows 7 - DBMS: Oracle 11g Rel 2
Test: Dev. Studio 8008 /Windows 7 (Local) Output:HTML, EXL2K.
 
Posts: 1533 | Registered: August 12, 2005Report This Post
Virtuoso
posted Hide Post
Creating Reports with WebFOCUS Language is also an excellent reference (search the technical documentation in IBI Web Wite).



Prod/Dev: WF Server 8008/Win 2008 - WF Client 8008/Win 2008 - Dev. Studio: 8008/Windows 7 - DBMS: Oracle 11g Rel 2
Test: Dev. Studio 8008 /Windows 7 (Local) Output:HTML, EXL2K.
 
Posts: 1533 | Registered: August 12, 2005Report This Post
<José Andrés Vargas Aguilar>
posted
Hy, recap can be usefull when calculating custom sums or percentages between columns.

But on this case I need to calculate the difference (that is A - B) between two rows.
I know that on my By I'll always have two dates, not more. And I need to show amount_of_date_1 - amount_of_date_2.
 
Report This Post
Expert
posted Hide Post
You might be able to use the LAST function to refer to the date of the preceeding row, i.e. DATE - LAST DATE.


Ginny
---------------------------------
Prod: WF 7.7.01 Dev: WF 7.6.9-11
Admin, MRE,self-service; adapters: Teradata, DB2, Oracle, SQL Server, Essbase, ESRI, FlexEnable, Google
 
Posts: 2723 | Location: Ann Arbor, MI | Registered: April 05, 2006Report This Post
<José Andrés Vargas Aguilar>
posted
Here I illustrate it better this time:

ACROSS FIELD
TYPE 1 TYPE 2 TYPE 3 ...
BY1 DATE1 AMOUNT1 AMOUNT2 AMOUNT3 ...
DATE2 AMOUNT1 AMOUNT2 AMOUNT3 ...
BY2 DATE1 AMOUNT1 AMOUNT2 AMOUNT3 ...
DATE2 AMOUNT1 AMOUNT2 AMOUNT3 ...
. . . . . ...
. . . . . ...
. . . . . ...

And I need something like this:

ACROSS FIELD
TYPE 1 TYPE 2 TYPE 3 ...
BY1 DATE1 AMOUNT1 AMOUNT2 AMOUNT3 ...
DATE2 AMOUNT1 AMOUNT2 AMOUNT3 ...
Difference: And here I'd display the difference of the two above values.
BY2 DATE1 AMOUNT1 AMOUNT2 AMOUNT3 ...
DATE2 AMOUNT1 AMOUNT2 AMOUNT3 ...
Difference: And here I'd display the difference of the two above values.
. . . . . ...
. . . . . ...
. . . . . ...

 
Report This Post
Virtuoso
posted Hide Post
Basic WF doesn't do inter-row calculations very well unless you use FML (lots of examples of that on the forum and in the manuals.)

However, what you're showing doesn't seem to require that. You can make whatever calculation you want and just put them in a subfoot. Using Ginny's suggestion of the LAST function calculate amount - last amount and then show it in a subfoot on the next line.


Regards,

Darin



In FOCUS since 1991
WF Server: 7.7.04 on Linux and Z/OS, ReportCaster, Self-Service, MRE, Java, Flex
Data: DB2/UDB, Adabas, SQL Server Output: HTML,PDF,EXL2K/07, PS, AHTML, Flex
WF Client: 77 on Linux w/Tomcat
 
Posts: 2298 | Location: Salt Lake City, Utah | Registered: February 02, 2007Report This Post
<José Andrés Vargas Aguilar>
posted
Excuse me guys I'm pretty new and still not too familiarized with webfocus.

I've found examples of the LAST command being used in DEFINE's and then being printed with the rest of values.

I'd only need to print it once every each BY.
How do I do that?
Where do I use the LAST?

Thanks.
 
Report This Post
Virtuoso
posted Hide Post
José Andrés, try this:

DEFINE FILE CAR
SEAT_BUCKET/A1 = IF SEATS GE 4 THEN 'B' ELSE 'A';
END
TABLE FILE CAR
SUM
        DEALER_COST
        RETAIL_COST
COMPUTE DEALER_COST_A/D10 = IF SEAT_BUCKET EQ 'A' THEN DEALER_COST ELSE 0; NOPRINT
COMPUTE RETAIL_COST_A/D10 = IF SEAT_BUCKET EQ 'A' THEN RETAIL_COST ELSE 0; NOPRINT
COMPUTE DEALER_COST_B/D10 = IF SEAT_BUCKET EQ 'B' THEN DEALER_COST ELSE 0; NOPRINT
COMPUTE RETAIL_COST_B/D10 = IF SEAT_BUCKET EQ 'B' THEN RETAIL_COST ELSE 0; NOPRINT
BY COUNTRY
BY SEAT_BUCKET NOPRINT
ON COUNTRY RECAP
DEALER_DIFF/D12 = DEALER_COST_B - DEALER_COST_A;
RETAIL_DIFF/D12 = RETAIL_COST_B - RETAIL_COST_A;
ON COUNTRY SUBFOOT
"Difference <DEALER_DIFF<RETAIL_DIFF"
ON TABLE PCHOLD FORMAT HTML
ON TABLE SET STYLE *
TYPE=SUBFOOT, BY=COUNTRY, HEADALIGN=BODY, JUSTIFY=RIGHT, $
END


It'll hopefully give you some ideas you can apply to your particular need.



Prod/Dev: WF Server 8008/Win 2008 - WF Client 8008/Win 2008 - Dev. Studio: 8008/Windows 7 - DBMS: Oracle 11g Rel 2
Test: Dev. Studio 8008 /Windows 7 (Local) Output:HTML, EXL2K.
 
Posts: 1533 | Registered: August 12, 2005Report This Post
<José Andrés Vargas Aguilar>
posted
Thanks nijsden.

Although your solution didn't work for me it got me thinking on how to make it with FML.

And I managed to make it.

After all my accross's and BY's y just added some FML for the 2 rows of dates (dates I know 'cause they're part of the parameters of the report).

FOR FECHATEXTO
'&wf_fchref1' AS '&wf_fchref1' LABEL R1 OVER
'&wf_fchref2' AS '&wf_fchref2' LABEL R2 OVER
BAR AS '-' OVER
RECAP R4 = R1 - R2; AS 'Diferencia' OVER
BAR AS '='

Where FECHATEXTO is my date field.

Thanks a lot to all of you!
 
Report This Post
Virtuoso
posted Hide Post
Well, I'm glad you found yet another way to skin the cat Wink



Prod/Dev: WF Server 8008/Win 2008 - WF Client 8008/Win 2008 - Dev. Studio: 8008/Windows 7 - DBMS: Oracle 11g Rel 2
Test: Dev. Studio 8008 /Windows 7 (Local) Output:HTML, EXL2K.
 
Posts: 1533 | Registered: August 12, 2005Report 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] CALCULATE "SUBHEAD" FIELD

Copyright © 1996-2020 Information Builders