When you configure how numbers display, you select the number of decimal places to show. Crystal Reports then rounds the display value to that decimal position and that is what you see.
But what if you want to display the actual number? If the original number has no decimal places, you want to see that. If the original has three decimal places, you want to see all three.
You can do this using conditional formatting.
- Right click on the number field and select Format Field from the pop up menu. You see the Format Editor dialog.
- On the Number tab, click the Customize button. You see the Custom Style dialog.
- On the Number tab, click the Conditional Format button next to the Rounding option. Enter the following formula:If CurrentFieldValue = Int(CurrentFieldValue)Then 0ElseIfCurrentFieldValue * 10 = Int(CurrentFieldValue * 10)Then 1ElseIfCurrentFieldValue * 100 = Int(CurrentFieldValue * 100)Then 2ElseIfCurrentFieldValue * 1000 = Int(CurrentFieldValue * 1000)Then 3ElseIfCurrentFieldValue * 10000 = Int(CurrentFieldValue * 10000)Then 4ElseDefaultAttribute
- Click on the Conditional Format button next to the Decimal option and paste the same formula.
- Click on OK twice to return to your report and view your formatting changes:
This will show the correct values up to four decimal places. If you need to accommodate more decimal places, you can expand the formula by adding more IF statements.
ref : http://crystaltricks.com/wordpress/?p=176#more-176
No comments:
Post a Comment