display specific number of significant figures rather than decimal places in crystal reports 2008 - crystal-reports

Good Morning!
I am working in Crystal Reports 2008 & have a report template that I'd like to use with various dynamic parameters (called in a downstream application).
My data can vary from being on a scale of 0-1 to a scale of 1,000-10,000.
I'd like to display it with 3 significant figures so when the report pulls in a dataset that
looks like this --> displays like this
0.76895 --> 0.769
0.6672 --> 0.667
1.0335 --> 1.03
but when the data set
looks like this --> displays like this
12,125.65 --> 12,100
956.35 --> 956
4,352.22 --> 4,350
My current work around is to make two templates-- one to use with my small value data, set to display 3 decimal places; and another to use with my large value data, set to display no decimal places.
I was wondering if there was a way to set significant figures displayed rather than decimal points?
Oh! I would do it in SQL first and pass it in as a string but I need these as numeric values so I can summarize them elsewhere in the report. Thanks.

If you right-click on your numeric field and choose format, Customize..under the number tab you get a bunch of choices to set the decimal separator, how many decimals to display, etc. choosing the formula button next to Decimals, you could put in a formula that looks at the amount of digits after the decimal dot and then either set the decimals to 2 if there are more than 3 decimals, and to zero decimals if there are 2 decimals. They key here is to get the order right. You want to check for the 2 decimals first and then for 3 or more decimals. If you do it the other way around the formula will display everything without decimals.
Hope that helps,
Chris

Use something like this.
ToNumber(Totext(<<DatabaseField>>,0,""))

Related

Tableau rounds my numbers to 16 decimals on import. How can I stop this?

When connecting to a data source and importing data into Tableau decimals are limited to 16 places. I have large decimals that are being multiplied by millions of products so these rounding errors are affecting my end calculations.
I made sure the data type is coming in as Number (decimal).
I would like the data to be imported into Tableau un-rounded.
Tableau, like Excel, uses floating point precision for its numbering system.
This means that Tableau will only provide 15 digits of precision for numbers.
If this were for display purposes, I would suggest bringing the numbers in as strings. See this similar answer. However, because mathematical operations are being performed, the precision is unavoidable.
If possible:
Perform mathematical operations elsewhere. For example, a custom SQL query that will bring the table to Tableau with operations already complete.
Try to operate in a smaller scale - instead of multiplying by millions, multiply by hundreds/thousands and change the name of the field to represent the scale. (ie: 'thousands of millions' instead of billions.) Something like this perhaps.

Formatting a numeric field to fixed length in crystal reports

I have a crystal report where a numeric field needs to be a fixed length with a decimal and needs to not round up or down. I changed it to a text field but now when I run the report and I forget to change the options in crystal for a number field to show ####.## it rounds to nearest dollar amount and drops the cents. How can I fix it so I won't have to remember to change the options?
An example may be helpful -
If the field is numeric, or decimal, you can right click the field, select "format field", click Customize, Number, and select the rounding and decimal logic.
if you don't have enough decimal places allowed (say, zero decimals) then make sure the rounding is not set to "1" - that would cause the number to round up. if the rounding is less than or equal to the decimal places, it should just 'truncate' and not round.

How to remove 2 decimal places without rounding in a running total in CR?

I have a number field in my database that contains four decimal places. I have a running total in my Crystal Report that sums this field. I am attempting to not round and only show 2 decimal places.
Example:
My running total displays 809.47
I want it to show 809.46
Since the field from the database produces a sum of 809.4680, how can I just make it 809.46?
Any assistance would be greatly appreciated - thanks!

cdbl in crystal reports is giving wrong results in decimal points

Friends,
This is the formula in the crystal reports 9.
cdbl({nrconsolidated.collamt})/100000.000
nrconsolidated table is having 9 records.
in that one record's collamt value is 154250.
but in the crystal reports output its showing as 1.543 instead of 1.542.
i want only 3 decimal points.i dont know where the mistake is coming from?
in the crystal reports, i clicked on that collamt field and checked the data by seeing the browseData option...its showing as 154250.
how can i solve this issue? its showing the correct value in 4 decimal points but i want only 3 decimal points.
thanks
The below code will truncate the result after the calculation has been performed, and output it to 3 decimal places. This works for Crystal Syntax and should for Basic as well - I believe it is common amongst both.
truncate(cdbl({nrconsolidated.collamt})/100000.000,3)
On the field set the decimals 1.000 and rounding 0.001 will display what you want.

Display CR values as scientific notation

I have a series of very small positive and negative values stored in oracle which I am attempting to display in crystal reports. Crystal is displaying all the values as 0. However if I turn the max decimal places on I will see some values as 0.00...00XY.
I would like these values simply displayed as scientific notation with something like 1.2E-12.
It seems crystal automatically converts very large values to SN, but not very small values?
This is not possible so I went and created a view instead for each needed table. Kind of a dumb solution, but it seems the only way possible.