Search code examples
visual-studio-2019ssrs-2019

SSRS Pass Total Number of Rows from Master to Subreport


I have an SSRS report that contains a master page with a table, which passes the row data from the table to a subreport.

I would like to also pass the total number of rows contained in the table to the subreport.

I have tried setting a variable on the master page using both:

=CountRows("Assessment") 

and

=Max(Fields!ROWNUM.Value, "Assessment")

but when I then try to pass the variable to the subreport I get the error:

Error       [rsCyclicExpressionInReportVariable] The Variable(TOTAL_ROWS) expression for the report contains a direct or indirect reference to itself.  Loops in variable value expressions are not allowed.

If I try to put either of those expressions into the expression of the parameter directly (Subreport Properties -> Parameters, then fx) for the subreport, I get the error:

Exception of type 'Microsoft.Reporting.Services.ReportProcessing+DataCacheUnavailableException' was thrown

any idea how I get the total number of rows passed to the subreport?


Solution

  • So passing

    =Max(Fields!ROWNUM.Value, "Assessment")
    

    as the expression for a parameter does work, but if you are getting 'DataCacheUnavailableException' you need to delete the file "MasterFileName".rdl.data to essentially clear the report data cache.