cancel
Showing results for 
Search instead for 
Did you mean: 

Value of shared variable incorrect in calculations.

Former Member
0 Kudos

Hi All,

Hope someone can help as this has me beat!

I am doing a simple sales projection report, the only complication is that, being a global report, it needs to be run in a user selected currency.

I have a parameter in the main report to allow currency selection, and then a subreport in the header that calls the exchange rate file and stores this in a shared variable.

The detail sections then show potential sales in base currency and the report currency, i.e. potential value * rate shared variable.

The problem is that the formula in the main report does not see the rate correctly. To test it I created two formulae - the first multiplies potential by rate, the other multiplies potential by another formula which is just a hard coded '1.47'.

Selecting $ as the currency, I have the rate shared variable showing correctly in the detail as '1.47', but the formula that uses this sees it as 1.0018 for some reason, so instead of a correct value of $220,500.00 I get $220107.17.

Have spent nearly a day trying to track down the issue, so any suggestions at all welcome !

Accepted Solutions (0)

Answers (2)

Answers (2)

0 Kudos

Try changing the rounding option in the field by selecting the format for the numeric fields. Likely it errors are due to CR rounding the values.

Former Member
0 Kudos

- Ensure that you have included "WhilePrintingRecords" in all the formulae.

- Can you change the idea a bit and display the potential value * rate calculation in the subreport itself.

- It is like exactly the reverse of what you are currently doing.You will need to collect the required values from main rpt and pass them to sub rpt.Also, the sub rpt should be placed in the report footer of the main rpt.

Former Member
0 Kudos

Thanks for the suggestions.

'WhilePrintingRecords' was already in my formulae so it is not that.

I have tried your suggestion of doing the calculation in the subreport and that does not work either.

To give a bit more detail, I have 5 formulae -

@Potential = the value from the database,

@Rate = the exchange rate from the database (=1.47)

@x Rate = @Potential x @Rate

@1.47 = hard coded value of 1.47

@x 1.47 = @Potential x @1.47

These then print out in the order above, and as an example I see ...

@Potential; @Rate; @x Rate; @1.47; @x 1.47

219,818.79; 1.47; 322,561.00; 1.47; 323,133.74

which I get whether I calculate in the main report or the subreport

A calculator confirms 219,818.79 x 1.47 = 323,133.621 so there is a small error even in the direct calculation. (Another formula with simply '219818.79 * 1.47' gave the same error)

Obviously even though an error may be small it immediately raises concerns with users as to how reliable calculated results are in any Crystal report.