views:

848

answers:

1

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?

A: 

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.

Russ Bradberry
I have actually tried that approach as well, adding the visibility toggling expression to the column itself, the column header and the data field. No luck. It appears that it just isnt evaluating the expression
keithwarren7
that is correct, you have to actually change the data to be nothing and not toggle the visibility expression. So as a parameter you decide which columns to show or hide, then the dataset will not return data for those columns (or just a blank string)
Russ Bradberry