Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Decimal Number 1

Status
Not open for further replies.

FireGeek21

Technical User
Dec 12, 2007
218
0
0
US
Hi,

I need a formula that will force a number field not to round. It seems because of settings in File -> Options -> Fields tab -> Number -> Number tab my formula field is rounding to 2 decimal places. I need the full 4 decimal number to show. Cavaet is that this ends up displaying in a TEXT field. So, I can't just change the format of this field to show 4 decimals. I also can't change the Option settings - using Crystal on a Citrix server.

So, looking for a formula that can override the Option settings and will give me an unrounded 4 digit decimal. Tried ToText([field], "0.0000") and tried Truncate([field], 4) - neither work.

Thanks!

FireGeek
(currently using Crystal Reports XI with Lawson 9.01)
 
If you have a number field, you should be able to set the number of decimals (look for the .00 with an curved arrow). If you do not want to round a all, you can use the Truncate function in a formula. i.e., Truncate({Somefield},4).
 
This number field is actually part of another formula that has to display as a text. I can't use the formating option you suggest and as I previously mentioned, Truncate doesn't work.

FireGeek
(currently using Crystal Reports XI with Lawson 9.01)
 
Can't you truncate it before you convert it to text. If you are using totext, you can format the number.
 
As stated above, I have tried Truncate([field], 4). No success.

FireGeek
(currently using Crystal Reports XI with Lawson 9.01)
 
Seems to me that you'll have numbers (like 1.12345) formatted NUMBERS (like $1.12) and TEXT (like "$1.12")

The formatted number $1.12, still has an underlying value of 1.12345. Simply formatting a number does not change anything, except what is displayed. But a number is not equal to a TEXT value!

So is this what we're are talking about?

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
Hi Skip,

I have a FTE field that goes up to 4 decimal places. So, I have values of 1.0, .5, .75, .875, .5678. When I put this field in a report, the data with > 2 decimal places actually rounds - no formula, it rounds. If I format the field to 4 decimal places, it displays properly.

So, I have a formula field of ToText(Truncate({EMPLOYEE.FTE_TOTAL},4), "0.0000") because our vendor wants this field (and all the other fields in the report) to be text fields, right padded with a set amount of spaces, and for the report to be exported in a specific format. Unfortunately, my 0.875 is now showing as "0.8800 " and my 0.5678 is showing as "0.5700 ". I tried formatting the field. When the field is in here individually, it works find but then I can't right pad with spaces. I really need it to NOT round by itself.

Thoughts???

Tammy

FireGeek
(currently using Crystal Reports XI with Lawson 9.01)
 
Well text and numbers are totally different animals. If you round 0.875 to 2 places, as a number it will display as 0.88, as opposed to using ToText with .0000, you'll see "0.8800"

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
@Skip, I know about rounding rules. I DO NOT want it to round and it is rounding.
- The actual data is 0.875
- Put field directly into the report and it shows 0.88
- My formula is showing 0.8800

*** I want to see 0.8750. I DO NOT ROUNDING. The Truncate([field], 4) is NOT working. I can't just format the field because it is to be part of a formula that pads spaces after it.

UGH!

FireGeek
(currently using Crystal Reports XI with Lawson 9.01)
 
If I format the field to 4 decimal places, it displays properly."

????

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
OK - so, how do you pad spaces at the end of it so I get "0.8750 " ??

FireGeek
(currently using Crystal Reports XI with Lawson 9.01)
 
You're confusing TEXT with NUMBER

Trailing & leading ZEROS are meaningless as NUMBERS

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
Skip, It's not difficult... I have a number I need to convert to a text field so I can pad with spaces at the end. This is a file specification I did not write. PROBLEM: My number is rounding and I DO NOT WANT IT TO ROUND BEFORE I CONVERT IT TO TEXT USING ToText FUNCTION AND THEN PAD WITH SPACES!

@Skip, Please stop posting if you just want to keep arguing with me. I have been creating complicated Crystal Reports for many years. I am not a beginner user. I suspect this is a bug or too simple that I can't see the solution. Please read my requirements and what I have tried. Seems you are ignoring both.

FireGeek
(currently using Crystal Reports XI with Lawson 9.01)
 
totext({YourNumberField},4) works for me with all your example figures.

And I second your emotion.
 
THANK YOU BETTYJ!!!

The link provided some great information for what I needed to do. I ended up moifying it and now I have a solution that is working!!!

What the link didn't use that I ended up using was WhilePrintingRecords. There must be something going on with the order of processing. As mentioned initially, we have settings in File -> Options -> Fields tab -> Number -> Number tab that sets all numbers to a 2 digit decimal. I believe this is what was causing my rounding issue. I also believe this setting was preventing ToText([field], "0.0000") from working. Maybe in the grand order of processing, the "WhilePrintingRecords" is what helps???

I have used WhileReadingRecords and WhilePrintingRecords in the past. LBASS's formula in the link did not use either of these but I did. My end result that is working for me:

Code:
WhilePrintingRecords;
StringVar x   := ToText({EMPLOYEE.FTE_TOTAL}, 4, "");

x;

Thank you Betty J for the direction! It was good code I will keep for future reference!

Tammy

FireGeek
(currently using Crystal Reports XI with Lawson 9.01)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top