Count rows of a filtered tablix in SSRS

TechnicalSmile picture TechnicalSmile · Jun 8, 2012 · Viewed 25.1k times · Source

I want to show row count of my filtered tablix in a text-box inside my SSRS report header. I googled quite a bit but nothing helped.

Suggestion at this link gives me count but that is restricted to count of rows coming on current page. Even if my result has 2 pages, I get count of rows in first page only.

I also tried by adding a new column for row number and then show it's value in header's text-box but the problem remain same as above.

I tried using global shared variables in report(I am using custom code for filter), this helped upto an extent but they keep on accumulating value every-time I click view report button :(

Also please consider that moving filter criteria in stored procedure is not an option for me.

Thanks, Ravi

Answer

glenn380 picture glenn380 · Feb 6, 2015

The solution below worked like a charm for me. It's from a post by QuestionDude on the asp.net forum here:

  1. Add a row to the bottom of the tablix outside of the detail group.
  2. In any cell in this "footer" row, set the expression to =COUNT("Fields.[pick a field].Value"). Always paranoid, I used a unique field. Not sure it matters. Let's call that cell Textbox17.
  3. Outside of the tablix, you can use the expression ReportItems!Textbox17.Value to display the row count of the filtered tablix.
  4. Hide the footer row.

All credit to QuestionDude.