How to sum values from Tablix and Sub reports

Ysa8989 41 Reputation points
2021-11-16T21:51:20.697+00:00

Hello

I need to get the total from the Tablix and the value from the sub report, I was trying to use the ReportItems but it did not work

I was trying to lookup the amount I need but the lookup did not bring any value,

SQL Server Reporting Services
SQL Server Reporting Services
A SQL Server technology that supports the creation, management, and delivery of both traditional, paper-oriented reports and interactive, web-based reports.
2,990 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Isabellaz-1451 3,616 Reputation points
    2021-11-17T01:05:30.64+00:00

    Hi @Ysa8989
    There is no common method to access data in a subreport. The SSRS model is that parent report data is processed, subreport data is processed, the subreports are rendered, results go back to the parent, then parent is rendered, including the subreport as appropriate. The only data passed between the two is parameters are passed into the the subreport, and rendered output is passed back to the parent.

    For more information,please refer to :https://stackoverflow.com/questions/19279412/ssrs-pull-variables-or-values-from-sub-report-into-main-report

    Best Regards,
    Isabella


    If the answer is the right solution, please click "Accept Answer" and upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

  2. Joyzhao-MSFT 15,601 Reputation points
    2021-11-17T01:59:15.137+00:00

    Hi @Ysa8989 ,
    With reporting services to pass values from subreport in to main report is not supported directly.

    But there are some workarounds through which you can get this .

    There are two ways to get this.

    1. Put your sub report query into some tables. I mean to say through the subreport query get some temporary table.
    2. Using this temporary tables data write some Scala function in the database (The premise is that you are familiar with the use of Scala functions).
    3. Now in your main report query return this scala function as a column.
    4. Extract the column value where ever you want in your main report which is getting calculated from the subreport query. so you will be getting the values returned from the subreport in the main report.

    This will definitely work fine as somebody have done some reports in this way.

    Another way of doing is that:

    1. prepare another dataset with the same query as in subreport in the data tab.
    2. then refer this 2nd dataset in your main report .

    Best Regards,
    Joy


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.