Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 950
keithwarren7 Avatar asked Jan 20 '10 21:01

keithwarren7


2 Answers

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.

screenshot

like image 55
user2765864 Avatar answered Oct 23 '22 05:10

user2765864


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.

like image 38
Russ Bradberry Avatar answered Oct 23 '22 04:10

Russ Bradberry