Focal Point
[SOLVED] Adding K or M or B after Rounding Number Dynamically

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

February 06, 2014, 12:12 PM
RaviD
[SOLVED] Adding K or M or B after Rounding Number Dynamically
I have a report and I need to show the amount in Millions or Billions or in K’s dynamically. Is that possible to add after rounding number like M or B or K?

Ex: if Sales is 100000 then I need to show 100K

Ex: if Sales is 1000001 then I need to show 1.1M

Any Example appreciated

This message has been edited. Last edited by: <Kathryn Henning>,


WebFocus 8202M
APP Studio
Info assist
Report caster
Portals
Maintain
EXcel,PDF,HTML,Active Reports
February 06, 2014, 04:02 PM
j.gross
That's an odd way of rounding.

But whatever your rounding method, here's a sketch (untested!):
define file ...
-* first compute the rounded values, for example... (P format ensures wysiwyg)
sales /P12.1 = sales_field;
salesk/P12.1 = sales / 1000 ;
salesm/P12.1 = sales / 1000000 ;
salesb/P12.1 = sales / 1000000000 ;
-* determine the scale factor (and suffix) for displaying the value
sales_type/A1=
     if abs(salesb) gt 0 then 'B'
else if abs(salesm) gt 0 then 'M'
else if abs(salesk) gt 0 then 'K'
else ' ';
-* ... and the scaled value
sales_value/D12.1=
     if sales_type eq 'B' then salesb
else if sales_type eq 'M' then salesm
else if sales_type eq 'K' then salesk
else sales;
sales_display/A16 = fprint(sales_value, '(D12.1)', 'A15') | sales_type ;
end



- Jack Gross
WF through 8.1.05
February 06, 2014, 08:10 PM
RaviD
Perfect, That works.
only I relaced following in your code.

SALES_VALUE_A/A25 = FTOA(SALES_VALUE,'(D12.1)',SALES_VALUE_A);

Thanks Gross.


WebFocus 8202M
APP Studio
Info assist
Report caster
Portals
Maintain
EXcel,PDF,HTML,Active Reports