Crystal Report: Formatting the Decimal Field into Integer

Even though I am currently working in SharePoint I still have a fond of working in crystal reports. Recently in the MSDN forums I saw a requirement in Crystal Report forums section. The requirement is that there is a decimal type column in the SQL Server Database as Shown below.

When we connect the DB in the crystal report, we got the output like this.
But the output should show something like; if the Decimal Field value has no decimal value then it should show as integer without decimal places. If the Decimal Field value contains some decimal value data then it should be left as it is.

Solution:
In the Crystal Report, Right Click the Decimal Field we have placed in the Detail section and select Format Object.

In the Format Editor window select Custom Style under Style and click Customize button.

In the opening popup window select Number tab and click the Formula Editor Button next to Decimals:

Enter the formula as shown.

Click Save and Close in the Formula editor and click Ok in Custom Style window

Now the Output in the Crystal Report is come as Expected.

0 comments:

Post a Comment