locked
Add two cells from two different tablix? RRS feed

  • Question

  • How can I sum two values, each from a different tablix?  I can't seem to reference those cells no matter what I do.
    Monday, February 25, 2013 7:14 PM

Answers

  • Hi Mini,

    As the error message said, report item expressions can only refer to other items within the same grouping scope or a containing grouping scope. In this case, we can use custom code to avoid this issue.
    Public Shared Value as Integer=0
      Public Shared Function GetValue(Item as Integer) as Integer
         value= value + Item
         return Item
      End Function
      Public Shared Function GetTotal()
         return value
      End Function

    Then use the expression in the cells which you want to calculate.
    =Code.GetValue(Fields!Column.Value)
    and use the expression below to get the total of them.
    =Code.GetTotal()

    If you have any questions, please feel free to ask.

    Regards,


    Charlie Liao
    TechNet Community Support

    • Marked as answer by Charlie Liao Monday, March 4, 2013 1:21 AM
    Wednesday, February 27, 2013 6:00 AM

All replies

  • Try using =ReportItems!CellName1.Value + ReportItems!CellName2.Value

    Replace CellName with the names of the cells you want to Sum

    Monday, February 25, 2013 7:23 PM
  • It says I cannot reference items outside the group.
    Monday, February 25, 2013 7:36 PM
  • Hi,

    You can refer within a tablix but not outside. As I know , it refers only the same containing group scope


    Please Mark as Answer if my post solved your problem or Vote As Helpful if this helps. Blogs: www.sqlserver2005forum.blogspot.com

    Monday, February 25, 2013 7:59 PM
  • Hi Mini,

    As the error message said, report item expressions can only refer to other items within the same grouping scope or a containing grouping scope. In this case, we can use custom code to avoid this issue.
    Public Shared Value as Integer=0
      Public Shared Function GetValue(Item as Integer) as Integer
         value= value + Item
         return Item
      End Function
      Public Shared Function GetTotal()
         return value
      End Function

    Then use the expression in the cells which you want to calculate.
    =Code.GetValue(Fields!Column.Value)
    and use the expression below to get the total of them.
    =Code.GetTotal()

    If you have any questions, please feel free to ask.

    Regards,


    Charlie Liao
    TechNet Community Support

    • Marked as answer by Charlie Liao Monday, March 4, 2013 1:21 AM
    Wednesday, February 27, 2013 6:00 AM
  • To refere to an item from another Table you need to specify name of DataSet explicity to which your other Tablix is bound to. So, to sum two values you need to write

    Sum(Fields!Field1, "OtherDataSetName") + Fields!MyFieldInCurrentDS

    Wednesday, February 27, 2013 6:32 AM