48

Is there a way to set a table's visibility to false, if the table has no rows?

I want to hide a table in Reporting Services when it has no rows.

Setting NoRows to ="" isn't sufficient in this case as space is still left for the table, and some of the table's formatting is still visible.

I'm using Microsoft Visual Studio / SQL Reporting Services 2005

1
  • I have never experienced this. If there is no data for the table to display, then nothing happens - unless you've filled in the NoRows. Is there some other value in the table that is not related to the core dataset? Apr 21, 2009 at 6:56

2 Answers 2

121

Try setting the table's "Visibility.Hidden" property to this expression:

=CountRows() = 0
5
  • Should it be =CountRow() == 0
    – Chris KL
    Feb 5, 2009 at 23:58
  • 12
    No, Reporting Service's internal expression language is VB, which just uses a single = for comparison (as well as assignment). Feb 6, 2009 at 0:23
  • 2
    My expression always seemed to do the opposite of what I expected. No wonder, the expression is setting "Visibility.Hidden" as opposed to "Initial visibility" as the dialog implies. Grrrrr!
    – Even Mien
    May 21, 2010 at 19:00
  • Just solved my problem, and also someone else in my team's problem! Awesome and so damn elegant.
    – CLockeWork
    May 19, 2014 at 12:31
  • 8
    If you want to use this on an object outside of the tablix/chart e.g. a textbox you need to add the scope, e.g. =CountRows("Physical_Servers")=0 where the dataset is called Physcial_Servers. Feb 23, 2015 at 11:33
20

Found the answer on my own, it's pretty simple.

I found this article which mentions the CountRows() function.

So to set the Visibilty / Hidden property to hide when there are no rows, it's simply

= Iif (CountRows() > 0, false, true)

Not the answer you're looking for? Browse other questions tagged or ask your own question.