Thursday, April 30, 2015

SSRS

Hi shilpa288,

Per my understanding that you have two tables and you create two datasets related to the two tables, now you want to sum the Total_Qty which comes from the table2 to display in the report based on table1 which grouped by the field "Date", right?

As you want to get the SUM(Total_Qty) grouped by the date, so I assumed the field date, Company_code  in the table1 are the same with that in the table2. If so we can use  the lookup function to get the field "Total_Qty" to display in the report and then use the expression " SUM(Total_Qty,"Date")" to get the total sum.

Details information below for your reference:

  1. Before use the lookup() function, make sure your SSRS version is 2008 R2 or later, or it will not support this function.
  2. Make sure you have an relationship field which is unique to be involved in this function, for example: Company_code, then you can add expression like below:
    Expression1:
    =Lookup(Fields!CompanyCode.Value,Fields!CompanyCode.Value,Fields!TotalQty.Value, "DataSetB")
  3. Right click the row group "Date" to Add total after, use below expression to sum the total:
    Expression2:
    =SUM(Lookup(Fields!CompanyCode.Value,Fields!CompanyCode.Value,Fields!TotalQty.Value, "DataSetB"),"Date")
  4. Preview like below:

More details information about the Lookup() and LoopupSet() function:
Lookup Function (Report Builder and SSRS)
LookupSet Function (Report Builder and SSRS)

If your data is not suitable to use the Lookup() or LookupSet() function, I will suggest you to modify the query to join the two tables to get the sum and not create two seperate datasets.

If you still have any problem, please try to provide sample data and more details information.

Regards,
Vicky Liu


Vicky Liu
TechNet Community Support


No comments:

Post a Comment