cancel
Showing results for 
Search instead for 
Did you mean: 

How to display tiled sign when more then two decimal places

Former Member
0 Kudos

Hello Team,

We have received a requirement like below. Suppose we are printing one number field which contains the decimal places(i.e it may contain 2 or 4 or 10 or up to 14 decimal places).

My requirement is if the if the number contains more then two decimal places we need to display tiled symbol after two decimal places. Please let us know how can we achieve this.

Ex.

10.12354 is the original value

We need to display it like 10.12~

Thanks,

Chakradhar

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hello Abhilash,

Thanks for the replay we have tried it is working as expected up to 10 decimal places, but we need it for 14 decimal places. If we change from 10 to 12 getting an error like "crystal reports the number of decimal places is too large or not an integer". Please suggest us if you have any solution.

Thank you.

Chakradhar

abhilash_kumar
Active Contributor
0 Kudos

I believe, Crystal Reports has a limit of 15 or 16 digits, however, I'm not completely sure.

If you're receiving that error, the only workaround would be to convert that number to a string (using a Command SQL or SQL Expression).

The formula would also have to be modified if the field is a string.

-Abhilash

abhilash_kumar
Active Contributor
0 Kudos

Hi Chakradhar,

Create a formula with this code:

numbervar x := {number_field}; //Replace this field with the number field from your data source
numbervar intg := int(x);
stringvar dec := strreverse(totext(tonumber(strreverse(split(totext(x,3),'.')[2])),'#'));
totext(intg,'#') & if dec <> '0' then '.' & left(dec,2) & if len(dec) > 2 then "~"

-Abhilash

DellSC
Active Contributor
0 Kudos

I would use a formula to convert the number to a string, trim off trailing 0's, and then get the length of the part after the decimal point to determine whether to show the tile. The formula might look like this:

{@ShowTile}
WhilePrintingRecords;
StringVar numstr := ToText({field},14, "",'.');
NumberVar i;
numstr := Split(numstr, '.')[2]; //get the part after the decimal
i := length(numstr);
Do While (i > 0) and (numstr[i] = 0)
  i := i - 1;
Loop;
i > 2  //If there are more than 2 non-zero characters after the decimal point, return true, else return false

Put your tile image on the report where it needs to be. Right-click on it and go to "Format object...". Click on the formula button to the right of the "Suppress" checkbox (DO NOT check the checkbox!) and enter the following:

not {@ShowTile}

This will suppress the image if the decimal length is 2 or less.

-Dell