Bug Report B96859
Visible to All Users
Duplicate

Calculated Field

created 17 years ago

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

Comments (3)
DevExpress Support Team 17 years ago

    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

      DevExpress Support Team 17 years ago

        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.

        Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

        Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.