Search code examples
reporting-servicesssrs-tablix

How to fix number of blank rows in SSRS


I am working on an issue where I needs to fix number of rows for a tablix. I am using a SQL query for the reporting service. My query returns 1-4 rows depending on the parameter passed.

I want to show blank rows in case the number of rows are less than 4.

Example: If the query returns 2 rows then I need to display 2 rows with data and other 2 blank rows. Currently it displays only 2 rows. I am looking for a solution which displays blank rows as well

Thanks in advance.


Solution

  • As mentioned by @Sourav It will be a good option if you can adjust the Rows in the Database query. But, if you have no control over it, then you can follow these steps:

    1) After the data row insert four empty rows
    2) Right click on first empty row and set visibility expression as 
     =IIF(CountRows("MyDataset") < 4 ,False ,True)
    3) Right click on second empty row and set visibility expression as 
     =IIF(CountRows("MyDataset") < 3 ,False ,True)
    4) Right click on third empty row and set visibility expression as 
     =IIF(CountRows("MyDataset") < 2 ,False ,True)
    5) Right click on fourth empty row and set visibility expression as 
     =IIF(CountRows("MyDataset") < 1 ,False ,True)
    

    If the query returns 0 rows from the database and if you don't want to show the empty rows then you no longer need the 4th row.

    Here is more info on CountRow Funtion.