Consultor Eletrônico



Kbase 15382: How to suppress zeroes after decimal point in Report Builder
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   20/03/2002

Method I
---------
PURPOSE
=======
e.g.
Display decimal values : 123.40 as 123.4
123.00 as 123
There is NO INTEGER format to suppress zeroes after the decimal point.
This is very easily accomplished in 4GL by using the STRING function.
i.e. string(123.40) = 123.4
string(123.00) = 123

However the same function is different in Report Builder.
You have to specify the same format as the integer/decimal represented to
convert a number to character, so a suppression cannot be performed.
Hence a slightly long approach:

SPORTS database was used in the following example.
TABLE : INVOICE
DECIMAL FIELD : AMOUNT format "->>,>>9.99"

STEP 1
======


Define 3 calculated fields to achieve 3 possibilities of displaying the
decimal field.

1. twodigit ( when you have NO zeroes to suppress e.g. 123.04 )
string(Amount, "->>,>>9.99)

2. onedigit ( when you have only 1 zero to suppress e.g. 123.40 )
string(Amount, "->>,>>9.9")

3. nodigit ( when you have 2 zeroes to suppress e.g. 123.00 )
string(Amount, "->>,>>9")

NOTE
====
If there are > 2 decimal points then more fields will have to be defined
for possible display formats and the field in STEP 2 adjusted accordingly

STEP 2
======

Define another calculated field which will be a nested 'IIF' based on how
many zeroes to suppress. The above formats will be used to represent
result.

dispfield

iff(SUBSTRING(twodigit,LENGTH(twodigit) - 1) = "00", nodigit,
iff(SUBSTRING(twodigit,LENGTH(twodigit)) = "0", onedigit, twodigit))

STEP 3
======

In the query, where you want to display the AMOUNT field with
suppressed zeroes, use the calculated field 'dispfield'.


Method II
---------

This is a simpler version of the above method. However, this will replace the unknown value which maybe needed depending on your data. If you require the unknown value do not use this method.

1) Open your report
2) Click on the calculations menu and choose caculated field.
3) Choose new
4) Name this function anything you'll remember
5) In the expression enter the following;

IIF(field = 0.00, ?, field)

This basicly states that if the field in question (Please replace field with the field you want to check) is equal to 0.00 then return the ? value else return the proper field value.

6) Click ok and close to save and return to the report.
7) Now insert this field inplace of the old field
8) Now right click on this new field and choose unknown value.
9) Just enter a space in place of ? and click ok

Now it will return a blank space instead on .00 in your reports.