SSRS: Suppressing hidden row groups on Tablix when exporting to Excel - reporting-services

Can Excel render only the visible row groups on a report?
I have a report [SSRS 2017] that has nested row groups on the Tablix.
The child groups are hidden by default, toggled by a report field. When you run the report, the default view displays just the summary rows.
Folks naturally try to export this to Excel (to work with just the summary rows) and of course When they export to Excel (collapsed or not) they get the grouped child rows:
Is there any way for SSRS to suppress hidden row groups when exporting to Excel (while still having a working toggle on the web version of the report)?
My fallback is to duplicate the report, remove the child row groups altogether, and just link to the "simplified" version of the report for that purpose.
thanks!

I haven't done this before but I have seen the theory for this once.
You would want to add an extra column and use it as the Toggle Item. Then set the visibility for the new column based on whether it's an EXCEL export.
=IIF(Globals!RenderFormat.Name="EXCEL" or Globals!RenderFormat.Name="EXCELOPENXML", True, False)
I haven't seen it work, so I don't know if will work the way you want.

The solution above does not work if you want to hide detail rows shown by drilling down.
For this case there's another way:
Create a boolean parameter to "suppress details" for example ExcelHide.
Create a copy of the tablix you want to hide the details from.
Set visibility parameter of the ORIGINAL tablix to the value of the parameter. This will HIDE this tablix when the parameter is true.
Set visibility parameter of the COPIED tablix to the negated value (not ExcelHide) of the parameter. This will SHOW this tablix when the parameter is false.
On the COPIED tablix, hide all elements you do not want to export to Excel.
When the report is run you set the parameter so you can show the details for regular operation and hide elements to allow successful export to Excel.

Almost there! I achieved this by setting the DataElementOutput property in my Tablix to "NoOutput", then prefixing the following to any fields in the rows I wished to exclude from my CSV export:
=IIf(Globals!RenderFormat.Name="CSV",Nothing,[YourValue])
Hope this helps folk and thanks [#Hannover Fist].

Related

Report Item not linked to a Dataset - tablix in Visual Studio 2015

I am trying to create a Report in SSRS and I have the below Table grouped by Closer -
I am trying to add a Pagename so each tab is separated by the Closer name when exported to Excel. When I go to Pagename in Table properties and click on "Expression" , I get Report Item not Linked to a Dataset for fields. How do I get to see the fields so I can pick it.
Any help would be greatly appreciated.
Thank you!
JHegde
The value for Pagename is set via the Tablix properties of Closer. Expand the "Group", the subgroup "PageBreak" appears, now set the value for the Pagename here.
Pagename can only be used in headers or footers.
Make sure within your Row Group properties of closer you have ticked "set between each instance of a group" - this creates the page tabs when exported to excel.
Click on a row or column header in the tablix and then click the tablix selector handle (4 pointed arrow) in the top left corner. This is just to ensure you have the tablix selected correctly.
Hit F4 and you should the datset property in the properties pane.
Select the correct dataset from the drop down list.
To be honest I'm surprised you are getting this error, as you have fields in the tablix and row groups already setup up. To do this, would mean you almost certainly had the dataset correct at the time. It could be that the setting was accidentally deleted I guess.. Anyway, try this and let us know how you get on.

SSRS 2008 R2 Bug? Still? Dynamically hiding column or tablix and exporting to CSV

I originally thought this would be an easy task, but after several hours of research I'm reading there may be a SSRS bug when exporting hidden fields to CSV which doesn't make this possible?
What I'm looking to do:
I have a report with several columns (let's say 50). I have a parameter drop down for REPORT_VERSION that allows the user to select "Standard" (all 50 columns) or "Express" (only 10 columns). I've been able to display the 2 versions correctly, but when I export (the express version) to CSV it shows all of the columns (and or tablixs) and not what the results look like.
I've read about and tried:
If I create 2 tablix and hide one based on the parameter value, the export to CSV still shows both the visible and hidden tablix.
If I use =IIF(Globals!RenderFormat.Name="CSV", True, False) - this doesn't work for CSV output
Changing DataElementOutput = NoOutput. This hides the columns or table from the CSV output, but this can't be dynamically changed based on a parameter value.
Could this be done in the "custom code" section via vbscript??
Many of the articles and threads I read through dated back to 2010-2012 so hopefully there is a solution now? I'm really at a less here.
Help would be greatly appreciated. Thank you
I was able to get this to work in SSRS 2008 and 2012 based on your attempt #2. I created a dummy report with a data source query of
SELECT 'value1' as col1, 'value2' as col2
I then added the following expression to Column Visibility to column2
=IIF(Globals!RenderFormat.Name="CSV", False, True)
Note that the true and false are reversed from your sample. When the report was generated, column 2 was hidden, but when exported to CSV, column 2 was present.
To incorporate your parameter into the visibility expression, you could do something like this
=Switch(
Globals!RenderFormat.Name="CSV", False,
Parameters!REPORT_VERSION.Value = "Standard", False,
True, True
)
This will set the hidden property of the column to false if rendered as a CSV, or if "REPORT_VERSION" parameter is set to "Standard", else hide the column. This expression would need to be added to the Column Visibility of every column you want to hide in the "Express" version of the report.
EDIT
OK, I understand the issue now and can replicate it (I was backwards on the concept). You can explicitly set the visibly of a column to hidden and it won't show up in a CSV export. However, when you attempt to control this via an expression, the CSV export ignores this setting.
Data based exports look to be controlled by the "DataElementOutput" property. Setting this to "NoOutput" will suppress this that element from the CSV output. Unfortunately, it doesn't appear it can be controlled by an expression. Microsoft does not appear to have any plans to change this(https://connect.microsoft.com/SQLServer/feedback/details/431073/ssrs-programatically-controlling-the-dataelementoutput-property)
The Microsoft connect request hints at creating two tablixes and filtering out all the results for each one based on the parameter supplied (i.e. "Express" or "Standard"), additionally hiding the other tablix based on the parameter value. I tried this and it worked halfway. Although the other tablix had no results, it would still export the column headers and one blank row.
Now I'd be curious to know what a good solution would be to this issue.

Show a message to the user instead of blank report [duplicate]

I am building an SSRS 2005 report using BIDS. My report filters on date. When the selected date returns no data rows the report is blank, just the title is displayed, no table or column heading.
How can I change this to display a message like No data available. or Report is empty.?
You could set the property NoRowsMessage available on the report's table control like this:
Select the Tablix control and press F4 to view the Properties pane.
Find the NoRowsMessage property and set the value to whatever message you'd like.
You can also to format the message using the Font and TextAlign properties.
Here are some examples of what the report will look like under various settings:
Further Reading: Here is a Technet article on how to Set a No Data Message for a Data Region
Avoid NoRowsMessage and build your own conditional empty row
One problem (or feature if that's what you want) with NoRowsMessage is that it'll literally replace the entire table with just a plain old message string.
Which provides a relatively counter-intuitive end user experience in my opinion. Normally when no data is found by a system, we'd like to know something about what data was being looked for and what it would have looked like.
Instead, based off how to keep the structure of the Tablix when there is no data to show, you can do the following:
Insert New Header Row, outside the group and above the details record.
Right click on the side of the new row and Set Row Visibility
Set Visibility to the following expression which will count the rows inside the current Tablix and only set Visibility to True if there is no data.
=CountRows() > 0
Optionally, merge the cells and add your own message or just display an empty row
Here's a comparison of how the various options will render: (pick whichever look you think best fits your data and use case)
Right-click on whatever databound element(s) you are using in the report and there should be a property NoDataMessage There are a host of options there but the Caption is the first element I would look at.

How do I display 'No data available.' when there are no rows to show on the report?

I am building an SSRS 2005 report using BIDS. My report filters on date. When the selected date returns no data rows the report is blank, just the title is displayed, no table or column heading.
How can I change this to display a message like No data available. or Report is empty.?
You could set the property NoRowsMessage available on the report's table control like this:
Select the Tablix control and press F4 to view the Properties pane.
Find the NoRowsMessage property and set the value to whatever message you'd like.
You can also to format the message using the Font and TextAlign properties.
Here are some examples of what the report will look like under various settings:
Further Reading: Here is a Technet article on how to Set a No Data Message for a Data Region
Avoid NoRowsMessage and build your own conditional empty row
One problem (or feature if that's what you want) with NoRowsMessage is that it'll literally replace the entire table with just a plain old message string.
Which provides a relatively counter-intuitive end user experience in my opinion. Normally when no data is found by a system, we'd like to know something about what data was being looked for and what it would have looked like.
Instead, based off how to keep the structure of the Tablix when there is no data to show, you can do the following:
Insert New Header Row, outside the group and above the details record.
Right click on the side of the new row and Set Row Visibility
Set Visibility to the following expression which will count the rows inside the current Tablix and only set Visibility to True if there is no data.
=CountRows() > 0
Optionally, merge the cells and add your own message or just display an empty row
Here's a comparison of how the various options will render: (pick whichever look you think best fits your data and use case)
Right-click on whatever databound element(s) you are using in the report and there should be a property NoDataMessage There are a host of options there but the Caption is the first element I would look at.

SSRS: Conditionally hiding columns based on parameter values - CSV export ignores

I have a simple table based report in SSRS 2008, There are 10 columns and each column has a corresponding parameter to determine whether the column should be shown. I achieve this by setting the Column Visibility option you get when right clicking on the column header in design mode. In my case I choose to 'Show or Hide based on an expression' to which I set the expression to the value of a parameter which is a boolean type.
The functionality works as expected during the initial render however when I choose to export the report to CSV the visibility expression is either ignored or not evaluated because the columns show up regardless of the setting.
The visibility dialog has three options, Show/Hide/Show Or Hide based on expression - If I explicitly set Hide option the CSV export does not include the column as you would expect however if I use an expression it will - I even went so far as to make the expression explicit like '=True' and still it was ignored.
How do I get the export option to evaluate this properly?
Here's a solution by KarenH in the article Hide/Show Items Dependant On Export Format
Basically, you can set the DataElementOutput = NoOutput on the control you want to hide.
This worked for me to hide tables when exporting to CSV.
You cannot hide or omit columns for the export, using expressions. This is because the expressions will only get evaluated in the report itself, not the export.
a workaround would be to hide the columns by default and show all others using the expression.
my apologies, that above statement made no sense. It seems what you will have to do is make a parameter that will show which columns to hide or display, then when the report runs just don't display any data in those columns. You can also change the value of the column heading based on these parameters.
The only other option is to create as many reports with the different column combinations then load the correct one dynamically.
I believe this may be a bug. I have used the Reporting Services export with hidden columns dependant on a parameter at runtime. If I run the report with the columns hidden and then export the result to Excel or PDF or most exports formats the hidden columns are NOT exported. If I export the report to a CSV file, the hidden columns ARE exported. Surely this is a bug in the CSV export.
Logically they should all behave in the same way.