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     Question: Rounding TOT., ST. in SUBFOOT, SUBHEAD

Read-Only Read-Only Topic
Go
Search
Notify
Tools
Question: Rounding TOT., ST. in SUBFOOT, SUBHEAD
 Login/Join
 
Gold member
posted
Hi all

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, 2007Report This Post
Virtuoso
posted Hide Post
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, 2007Report This Post
Gold member
posted Hide Post
Hi GamP,

Thanks for RECAP, I do not learn it yet.

But main issue remains:
It seems strange to me that rounding totals are made through two intermediate fields.

I have 10 fields in report that I need to round to thousands. So I have 20 additional NOPRINT fields.

I like brevity, "Succintness is Power"
Smiler

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, 2007Report This Post
Expert
posted Hide Post
Alex,

You should be able to -

ON COUNTRY RECAP
   SALES_RND/I10 = INT((SALES+500)/1000) * 1000;
ON COUNTRY SUBFOOT
"Sales: <ST.SALES"
"Sales rounded to thousands: <SALES_RND"

T



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
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, 2007Report This Post
Gold member
posted Hide Post
Tony,

Thanks, that's much better.

Darin,
Functions library : yes, I'm thinking about own function library.
One thing I do not like much in FOCUS - too much parameters in functions.

E.g.
SUBSTR(inlength, parent, start, end, sublength, outfield)

I never saw before substring function that have 6 arguments.


WF 7.6.2, WinNT/2K, MSSQL 2K, MSOLAP 2K, BID
 
Posts: 79 | Location: Moscow | Registered: April 27, 2007Report This Post
Virtuoso
posted Hide Post
Ingas

how about this function

Syntax: How to Replace Character Strings
STRREP (inlength, instring, searchlength, searchstring, replength, repstring, outlength, outstring)


....uspechow wam!




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
Gold member
posted Hide Post
Frank,

Yes!
I always forgot params of this function also.
Sometimes I feel like I'm programming in ASM =)

I think about own function library written on top of "official".

STRREP - must have 3 params not 8 =)


WF 7.6.2, WinNT/2K, MSSQL 2K, MSOLAP 2K, BID
 
Posts: 79 | Location: Moscow | Registered: April 27, 2007Report This Post
Expert
posted Hide Post
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.


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
Expert
posted Hide Post
Hi Ingas,

Here is another example:

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! Smiler

Cheers,

Kerry


Kerry Zhan
Focal Point Moderator
Information Builders, Inc.
 
Posts: 1948 | Location: New York | Registered: November 16, 2004Report This Post
Gold member
posted Hide Post
Thanks all!

Kerry, Tony - for samples how to use 1 COMPUTE field instead of two.

Darin, Ginny, Frank - for strengthing my intention to write own function library.

Best regards,
Alex


WF 7.6.2, WinNT/2K, MSSQL 2K, MSOLAP 2K, BID
 
Posts: 79 | Location: Moscow | Registered: April 27, 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     Question: Rounding TOT., ST. in SUBFOOT, SUBHEAD

Copyright © 1996-2020 Information Builders