After Creating a calculated field (of type decimal/float/double), with the expression
([ChgUnits] / [TotalUnits]) *100
The resultant value is always 0 (both Datatypes are Int32) (pending that TotalUnits >Chgunits)
However, using
(([ChgUnits]*1.0) / ([TotalUnits]*1.0)) *100
Gives the expected result
It would appear that the calculation is being performed as an integer calculation, unless forced into decimal by the multiplier.
Steps to Reproduce:
See description
Actual Results:
0
Expected Results:
A value
We have closed this ticket because another page addresses its subject:
Calculated Fields - Division result of the CalculatedField is truncated even if the CalculatedField.FieldType property is Double
Hello Mark,
I believe this behavior is by design. Naturally, the result of expression, which operates with data fields of integer type, is an integer value.
So, since there's no capability to use explicit cast conversion operators, you might need to multiply integer values by a decimal value, to avoid the problem.
Please let me know whether this makes sense.
Thank you,
Alex.
Perhaps then it may be worth clarifying this in the documentation associated with the calc'd fields!!
Yes I suppose it does make sense, hence why i used the *1.0 in it.
Also is it possible to get access to summary values within them ?
Eg, a sum of a % field is not the % accross the group, since it would need to be (sum(A)/Sum(B))/100 rather than just a sum of an individual line…
Perhaps access to a few more math operators like ABS for example (very useful when calculating a variance amount) would be useful also.
Cheers
Hello Mark,
Thanks for the feedback. We'll discuss the capability to update our documentation to avoid any misunderstanding.
Also, I believe you can use XtraReports summarizing abilities to calculate a summary across a group.
See this documentation topic: Calculating Summaries.
Sorry, there's no ABS operator available, so you might need to implement a similar operation manually.
And, you're always welcome to post a corresponding suggestion to our database.
BTW: Note that our Support Center concept doesn't allow you to post multiple problems within one thread.
In the future, post a separate issue for each question. This way, we can process and track it in a more efficient way.
Thank you,
Alex.