thnkwthprtls
thnkwthprtls

Reputation: 3487

SSRS 2012 - Hide table row containing a subreport with no data

I have a table with a details grouping containing two rows. The top row is several cells across with details on the data, and the bottom row is all columns merged to one cell, and that cell contains a subreport. This subreport has one parameter, which is the value of a cell in the top row. What I need is, when the subreport does not have any data to display for a particular value, for that row to not display at all. Right now it displays as a blank row between its top detail row and the next detail row. I can get it to display a "No Rows" message, but I don't want that, I just want it to not take up any space, ie the detail row would just be followed by the next detail row. I've found several similar answers like this: How to supress empty subreports in SSRS 2008, but as I said I need to NOT have a No Rows message. Thanks in advance

Upvotes: 0

Views: 1509

Answers (2)

Angel Gonzalez
Angel Gonzalez

Reputation: 1

One simple way that worked for me was as follows:

Select the row that will contain the subreport. Set the CanGrow and CanShrink properties to true. Insert the subreport into the row. Under SubReport Properties > Visibility > Show or hide… and add the following expression:

=IIF(RowNumber(Nothing)>0,False,True)

Then select the row again and use the handles to make the row as small as possible or as small as you like. When you run the main report the subreport will appear if it return records, otherwise the row will be blank and the height will be what you set above with the handles.

Upvotes: 0

Alan Schofield
Alan Schofield

Reputation: 21683

I 'think' the only way you can do this is to query the data from the main report and if no rows are returned, hide the row. If the subreport is a simple query then this should be OK but if it's a long running query then this will effectively double the execution time.

You have not given any clue as to the content of the subreport but if it was say, invoice lines for the invoice shown in the main report row then you might be able to modify your main dataset to include a count of records that would appear in the subreport and use that value to control the row visibility.

If this makes not sense, edit your question and post a screenshot of what you are trying to achieve and/or post a sample of the data that you are getting from both the main report and your subreport.

Upvotes: 2

Related Questions