none
Sum two fields in a row RRS feed

  • Question

  • Hi,

    Everytime I try to sum two fields it just doesnt sum, it unites them together like:

    Table: ID1 = 15; ID2 = 15.

    =ReportItems!ID1.Value + ReportItems!ID2.Value

    The output should be 30, but instead it gives me 1515.

    How do I solve this, so simple yet so dificult.

    Wednesday, June 12, 2019 3:10 PM

All replies

  • Hi,

    Use this :

    =CInt(ReportItems!ID1.Value) + CInt(ReportItems!ID2.Value)


    Ousama EL HOR

    [If a post helps to resolve your issue, please click the "Mark as Answer"  of that post or click Answered "Vote as helpful"  button of that post. By marking a post as Answered or Helpful, you help others find the answer faster. ]


     [User Page]     [MSDN Page]     [Blog]     [Linkedin]

    Wednesday, June 12, 2019 3:34 PM
  • It gives me #error :(
    Wednesday, June 12, 2019 3:41 PM
  • HI Vadim,

    What are ID1 and ID2? If them are textbox name. The expression should have worked.

    Are ID1.value and ID2.value string? Do you mind to share screenshot of this ID1&2?

    Lukas


    MSDN Community Support Please remember to click Mark as Answer; the responses that resolved your issue, and to click Unmark as Answer if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, June 13, 2019 2:08 AM
  • Hi Lukas,

    The screenshots are available below:

    imgur. com/a/PyDUofY

    Thursday, June 13, 2019 8:06 AM
  • I could not open it. 

    Could you try =cint(ReportItems!ID1.Value) to check if it will return 15 as value?


    MSDN Community Support Please remember to click Mark as Answer; the responses that resolved your issue, and to click Unmark as Answer if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, June 13, 2019 9:24 AM
  • Why don't you use the fields from the dataset to sum value :

    =Fields!ID1.Value + Fields!ID2.Value


    Ousama EL HOR

    [If a post helps to resolve your issue, please click the "Mark as Answer"  of that post or click Answered "Vote as helpful"  button of that post. By marking a post as Answered or Helpful, you help others find the answer faster. ]


     [User Page]     [MSDN Page]     [Blog]     [Linkedin]

    Thursday, June 13, 2019 9:49 AM
  • The datatype for that columns might be of string(ie., char or nvarchar or nchar or varchar or any other string types)

    So when you give a '+'  in between columns of a string it basically concatenates them or unites them together.

    Do this to get your problem solved. 

    --> first check the datatype of those columns

    use this query to check its datatype: exec sp_columns yourtablenamehere

    check type_name in that....

    if it is a text fields/string fields like I mentioned above....

    you have to cast them like this

    cast(yourcolumnname1 as int) +cast(yourcolumnname2 as int)..

    then you will get the required output

    • Proposed as answer by Ajay Pitta Thursday, June 13, 2019 10:49 AM
    Thursday, June 13, 2019 10:47 AM