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.
I'm puzzled with rounding in WebFOCUS. For example: I need to show totals rounded to thousands. I'm doing it in such way:
TABLE FILE CAR
BY COUNTRY
SUM
COMPUTE SALES_TH/I10 = SALES/1000; NOPRINT
COMPUTE SALES_RND/I10 = SALES_TH * 1000; NOPRINT
PRINT SALES
ON COUNTRY SUBFOOT
"Sales: <ST.SALES"
"Sales rounded to thousands: <ST.SALES_RND"
END
I have strong suspicion that this can be done more brief. I do not like creating two non-necesary fields just for something like: ROUND(ST.SALES/1000,0)*1000
I suppose that I miss something very simple.
Is it possible to make more brief?
Thanks in advance
WF 7.6.2, WinNT/2K, MSSQL 2K, MSOLAP 2K, BID
Posts: 79 | Location: Moscow | Registered: April 27, 2007
Ingas, If there is a ROUND function it would only work for D fields, since integers do not need rounding. Thus, you're on the right track for your problem. The code below is a little bit more transparent, and works just as well. One addition: for the first temp field you would have to add 500 to ensure a proper sounding. Converting to an I field will not do any rounding....
TABLE FILE CAR
PRINT SALES
BY COUNTRY
ON COUNTRY RECAP
SALES_TH/I10 = (SALES+500)/1000;
SALES_RND/I10 = SALES_TH * 1000;
ON COUNTRY SUBFOOT
"Sales: <ST.SALES"
"Sales rounded to thousands: <SALES_RND"
END
Let me know what you think....
GamP
- Using AS 8.2.01 on Windows 10 - IE11.
in Focus since 1988
Posts: 1961 | Location: Netherlands | Registered: September 25, 2007
I like FOCUS - in many tasks it is more brief than SQL. But sometimes I'm stuck in multiple holds, intermediate fields, MATCHes, etc.This message has been edited. Last edited by: Ingas,
WF 7.6.2, WinNT/2K, MSSQL 2K, MSOLAP 2K, BID
Posts: 79 | Location: Moscow | Registered: April 27, 2007
Sadly, there is no "magical function" in the language to round to tens, hundreds, thousands, etc. The code GamP and Tony provide would get you where you need to go. However, (as always) there is a little shortcut when you have a function that you commonly use that isn't available as a stock function. You can find documentation for creating your own user-written subroutines in the "Using Subroutines" manual available online.
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, 2007
Look up DEFINE FUNCTION. Without having to use a compiler, you can string together a series of commands, give them a name, pass it a variable, and get a result.
This feature has been around for awhile and is great for often-used calculations. You could -INCLUDE it in your focexec.
TABLE FILE CAR
BY COUNTRY
SUM SALES
COMPUTE MYSALES_RND/I10 =(INT((SALES/1000)))* 1000 ;
PRINT SALES
ON COUNTRY SUBFOOT
"SALES: <ST.SALES"
"SALES ROUNDED TO THOUSANDS ONE FIELD: <ST.MYSALES_RND"
END
Hope this helps. Many thanks to everyone's input!
Cheers,
Kerry
Kerry Zhan Focal Point Moderator Information Builders, Inc.
Posts: 1948 | Location: New York | Registered: November 16, 2004