Focal Point
[SOLVED] Rounding on Count Column

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/7177093766

February 19, 2014, 12:44 PM
ColdWhiteMilk
[SOLVED] Rounding on Count Column
My dataset has 100 records, and is sorted on a field called "Cycle Days'.

The report only shows the count of records for the lowest 90% of "Cycle Days" values in the dataset. So in the case of 100 records, it only displays 90 in the summary.

Sometimes this count value is off, which appears to be because WebFOCUS is only displaying the numbers to the left of the decimal place if the 90% is not a whole number.

For example, if there are 232 records, I get 208 from the CNT. field, but what I want is 209.

Is there a way to apply rounding to a "CNT." field?

DEFINE FILE TOTAL02
COL0/A50= 'New Hires;
END

TABLE FILE TOTAL02
SUM
CNT.CYCLE_DAYS AS '10PCTCUT'

BY COL0 AS 'METRIC'

ON TABLE HOLD AS 'NHCUT'
END

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


Production - 7.6.4
Sandbox - 7.6.4
February 20, 2014, 01:07 AM
jimster06
I might be confused but I believe the CNT varible to be an integer. Maybe you should be looking at a prior selection process.


jimster06
DevStu WF 7.6.11
W7
HTML, PDF, EXL2K
February 20, 2014, 10:33 AM
j.gross
I don't see how the 90% cut-off gets imposed -- apparently it's upstream from the code you posted, in a section that pulls TOTAL02 in the first place. And that's where your "rounding" issue would lie.

This message has been edited. Last edited by: j.gross,


- Jack Gross
WF through 8.1.05
February 20, 2014, 03:02 PM
jimster06
If you are doing the arithmetic using floating point numbers, consider using fixed point numbers so that you may have more control over the precision.
Take a look at 'half adjust' via Google for some insights re rounding.
HTH


jimster06
DevStu WF 7.6.11
W7
HTML, PDF, EXL2K
February 20, 2014, 03:13 PM
ColdWhiteMilk
the issue wsa, I believe, the calculation of 90% of records, versus trying to round the CNT. field.

IBI gave me the solution to apply when I calculate 90% of records from the hold file I'm using (I did not post my full code):

-RUN
SET DMPRECISION = 0
-SET &TOTAL01= &RECORDS;
-SET &TOTAL01PCT= &RECORDS * .90;
-TYPE &TOTAL01PCT
-EXIT



Production - 7.6.4
Sandbox - 7.6.4
February 24, 2014, 11:06 AM
Ram Prasad E
If your issue is resolved, then change the subject line of your initial post to [SOLVED]


WebFOCUS 8.1.05
Windows
http://ibiwebfocus.wordpress.com
https://www.facebook.com/groups/ibi.webfocus/
February 24, 2014, 04:22 PM
j.gross
quote:
-RUN
SET DMPRECISION = 0
-SET &TOTAL01= &RECORDS;
-SET &TOTAL01PCT= &RECORDS * .90;
-TYPE &TOTAL01PCT
-EXIT

You need a "-RUN" after the "SET DMPRECISION ..." line, so that it will control the "-SET" lines that follow.
February 25, 2014, 03:22 AM
Ram Prasad E
I tried without -RUN after SET DMPRECISION =0, it works fine in WF 8.0. But I remember in WF 7 release we need to explicitly mention -RUN after SET DMPRECISION=0. Not sure if IBI made any internal changes for this.


WebFOCUS 8.1.05
Windows
http://ibiwebfocus.wordpress.com
https://www.facebook.com/groups/ibi.webfocus/
February 25, 2014, 02:25 PM
j.gross
quote:
-SET &TOTAL01PCT= &RECORDS * .90;


That will truncate rather than round.

The right-hand side expression
&RECORDS * .90
is computed in floating-point, and then converted to an integer value (with truncation) which is stored in &TOTAL01PCT

You need to force rounding on the RHS:

-SET &TOTAL01PCT= INT((&RECORDS * .90) + 0.5);

(There used to be a function for rounding, but it was withdrawn from the product.)


- Jack Gross
WF through 8.1.05
February 25, 2014, 03:06 PM
ColdWhiteMilk
Thank you j.gross. This was the final piece I needed!


Production - 7.6.4
Sandbox - 7.6.4
February 28, 2014, 08:11 PM
Jim Morrow
An alternate approach

define a field to get the decimal places
10PCTCUT/P12.2 WITH CYCLE_DAYS = 1;
and use a sum verb or prefix


Jim Morrow
Web Focus 7.6.10 under Windows 2003
MVS 7.3.3