I am trying to create a formula field in Crystal Report XI that takes a monetary/numeric field and converts it to 10 characters with preceding zeroes, while dropping any commas or decimals. For example: 2,907.41 becomes 0000290741. Does anyone have any idea of how to do this?
totext(({table.number}*100),"0000000000")
Related
Crystal Reports 11.5 - I have tried to format the % objects in the cross-tab table to show 1 or 2 decimals but it is not saving. As a result the values are all rounded and so the sum of the sub totals does not add to 100% (sometimes only 97%) even the GT shows 100%.
How do I edit the format and save this?image show table sample with wrong values
I have a report in Crystal Reports 2013 that is grouping multiple transactions into an aggregate transaction by account number.
The value is Amount, so in the Group Footer is it listed as SumofAmount.
The field must be 17 characters long, so any number must be padded with leading zeros.
The values are assumed to be decimal, so they are all integers.
For example, the following transformations would occur:
3123 needs to be: 00000000000003123
23283792387 needs to be: 00000023283792387
If I right-click in Formula Workshop > Formatting Formulas > Group Footer #1 > SumofAmount I get a New Formatting Formulas which has leading zeros as an option, but how do I define this with a Boolean (this is a requirement)?
Right click on the field you need to have leading zeros.
select format field
select the common tab
select X2 to the right of Display String
Enter the following formula
right("000000000000000"&totext(CurrentFieldValue,"#"),15)
This assumes the total length of the field is 15. To change for your required length
change the number 15 to the desired length of the field
change the number of 0's between the quotes to at least the desired
length of the field
Repeat this for any field you need leading zeros
How do I round a formula result decimal value from 28.234 to 28.24 in crystal reports.
I am only getting 28.23 when I set the decimal to .00.
The field is formatted as a custom field: (decimal = 1.00 and rounding = 0.01).
Using Crystal Reports Version 2013.
Create a formula and use the RoundUp-function:
RoundUp(28.234, 2)
I am trying to add two zero place holders in front of a field without changing the actual values involved. The field is an order number that is being pulled from MOMs. So right now that fields' formula is {cms.ORDERNO}.
When I try '00'+{cms.ORDERNO} the field displays 001,254.00. How can I remove the decimals and comma so it displays 001254?
The usual trick is to pad with plenty of extra digits on the left and then only take the six you really want from the right. This would handle any order number ranging from 1 to 999999.
right("000000" + totext({cms.ORDERNO}, "0"), 6)
When you don't specify a format string, as you tried, it uses default settings which usually come from Windows. By the way, if I recall correctly cstr() and totext() are equivalent for the most part but totext() has more options.
You should also be able to specify "000000" as the format string to produce the left-padded zeroes. Sadly I don't have Crystal Reports installed or I'd check it out for you to be sure. If this is the case then you probably don't need a formula if you just want to use the formatting options for the field on the canvas. If you do use a formula it's still simple.
totext({cms.ORDERNO}, "000000")
You definitely want to use the Replace formula a few times for this. The formula below converts ORDERNO into string, removes any commas and trailing decimal places, then adds the two zeroes at the beginning:
`00` + REPLACE(REPLACE(CSTR({cms.ORDERNO}),".00",""),",","")
So for example, if cms.ORDERNO is 1,254.00 the output from this formula would be 001254
I know this is older, but better solutions exists and I ran across this same issue. ToText has what you need built right in.
"00" + ToText({cms.ORDERNO}, 0, "")
From the Crystal Documentation:
ToText (x, y, z)
x is a Number or Currency value to be converted into a text string; it
can be a whole or fractional value.
y is a whole number indicating the number of decimal places to carry
the value in x to (This argument is optional.).
z is a single character text string indicating the character to be
used to separate thousands in x. Default is the character specified in
your International or Regional settings control panel. (This argument
is optional.)
I am facing a strange problem in crystal report 2008
I have a table (mytable) with two columns col1 is string and col2 is float(15)
Below are values in table
Col1 Col2
AA 5.82518987E-5
BB 5.88383009E-5
Created a report in crystal report and placed mytable values on report for col1 it displays correct value but for COL2 it always displays FOR AA "0.0000582519" AND FOR BB "0.0000588383" instead of actual value in the table.
This is what in Crystal report instead of actual value.
Col1 Col2
AA 0.0000582519
BB 0.0000588383
Please help
Thanks
CR has the interesting limitation that the highest precision numeric value it can display is 10 decimal places (this includes trying to use the totext() function to cast the number to a string). This means that any float over that precision will be rounded at that tenth decimal.
Because of this and the fact that you're using a float which is precise up to 15 digits, the quick and dirty solution is to just manually convert to scientific notation by moving your decimal place over 5. You can accomplish this with something like:
totext({table.numeric} * 10^5,10) & "E-5"
Obviously, this will just indiscriminately convert all your numbers in Col2 to scientific notation whether they require it or not, so you may wish to add some additional conditional processing.
Note that if you Google "Crystal Reports scientific notation" you can find some custom functions to do that for you... but just be careful because a lot of these functions do not take the additional precision into account and WILL result in a much less precise number. In fact, the very first hit (HOw to display Number in Scientific Notation in version 2008) will chop that precision down to 10 digits in the very first line by using the totext() function.