Focal Point
[SOLVED] PCT. WITHIN Rounding Issue

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

September 04, 2015, 04:00 PM
Anatess
[SOLVED] PCT. WITHIN Rounding Issue
Hi guys,

I have a feeling I am missing something really simple. I can't seem to get the percentage to round out properly to the closest integer using PCT. WITHIN. SET DMPRECISION = 0 doesn't seem to make a difference. I apologize I don't have a CAR file example - it's just that I need precise data to get the condition I am talking about and I have a feeling this is something simple so I didn't spend the time to manufacture the data. If it seems necessary, I'll mock some up.

Anyway, here's the code:
  
TABLE FILE HOLD
SUM SNAG_COUNT/I9 AS ''
    PCT.SNAG_COUNT/I3% WITHIN CHKLST_TYPE AS ''
BY  DISPLAY_ORDER NOPRINT
BY  CHKLST_TYPE NOPRINT
BY  HIGHEST NCR_STATUS_DISP AS ''
END


In this example, SNAG_COUNT is D9.4. But the values in it are integers (as it is a count).
Here's a sample result:
1.00	RECEIVING	Open	316	62%
		Closed	191	37%
2.00	PREASSEMBLY	Open	0	0%
		Closed	44	100%




RECEIVING Closed should be 38% because the actual value is 37.6726. PCT.SNAG_COUNT truncates the decimals instead of rounding it. How do I get the rounding to apply to the PCT.?

Regards,
Anatess

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


WF 8.1.05 Windows
September 07, 2015, 09:20 AM
GamP
Just guessing here.
I think it is because of the redefinition of SNAG_COUNT/I9.
What if you tried this:
SUM SNAG_COUNT NOPRINT
    COMPUTE SNAGCOUNT/I9 = SNAG_COUNT; AS ''

That way the snag_count field will retain its original format, while the display of the field is still integer.
Again, just guessing - not tested, but worth a try.


GamP

- Using AS 8.2.01 on Windows 10 - IE11.
in Focus since 1988
September 08, 2015, 03:17 AM
Danny-SRL
Anatess,
quote:
  
TABLE FILE HOLD
SUM SNAG_COUNT/I9 AS ''
    PCT.SNAG_COUNT/I3% WITHIN CHKLST_TYPE AS ''
BY  DISPLAY_ORDER NOPRINT
BY  CHKLST_TYPE NOPRINT
BY  HIGHEST NCR_STATUS_DISP AS ''
END


What is the format of SNAG_COUNT?
I would assume that it is a D or a P field since you say that the value is 37.6726.
So, I would write:
  
PCT.SNAG_COUNT/D3% WITHIN CHKLST_TYPE AS ''

The D field should produce the rounding you want.


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

September 08, 2015, 05:36 AM
Wep5622
Format I (integer) always rounds down. Same for packed (P) if I recall correctly.

For proper rounding, use format D (decimal).


WebFOCUS 8.1.03, Windows 7-64/2008-64, IBM DB2/400, Oracle 11g & RDB, MS SQL-Server 2005, SAP, PostgreSQL 11, Output: HTML, PDF, Excel 2010
: Member of User Group Benelux :
September 08, 2015, 09:40 AM
Anatess
Thank you so much! D3% did it.


WF 8.1.05 Windows