Hide fields in SSRS report based on expression - reporting-services

i have one problem with exporting to CSV format. In my report i user parameter to hide on field and it's working ok except for exporting in CSV format.
Column visibility is see like this:
=IIF(Parameters!ShowBonusLockingData.Value="False",true,false)
but this doesn't work in CSV. Can someone help me with this problem. Setting column property to NoOutput is not a solution, because that property never shows the column then

Related

Issues exporting SSRS to CSV with textbox names

So I'm trying to export my SSRS to .CSV. The layout of my report is like this:
Everything does work fine, on my VS. However, when comes the time to generate it I get this:
I've read a few other post on Stack Overflow about how I can change my SSRS config for noheaders and ASCII. Thing is, people tried to set column names programatically, but here I only have expressions for cell contents and a current layout. Is there a way to make my CSV lay out look like my reportbuilder layout? Or is my problem the same as when people try to set the column programatically
For each data field you want to export set the DataElementName to match the field title and set the value to the DataElementOutput to output the field.
For the header textboxes set the DataElementOutput to NoOutput.
For more detail check the following microsoft link
https://msdn.microsoft.com/en-us/library/dd255251.aspx

Hide field when export to CSV in SSRS with expression

I want to hide one field in SSRS when I export the report. I know that if I put NoOutput property it will work but I have one more expression that I want to put for field visibility. I have this expression for my visibility and works fine for Excel, PDF,...
=IIf(Parameters!Limited.Value=false,false,true)
But when I export to CSV this doesn't work.
How can I improve this so that it also works for CSV?
You have to remember that there are 2 types of exports in SSRS:
Data export - CSV and XML
Image based export - Word, PDF, Excel, TIFF, printing
The visibility property will only be read when you export to an image based export, and the data output property will only be read when using a data export.
If you can live with having the column there with the data being blank, then use Aldrin's method. If you want the column to not be there when exported and the columns you don't want to export is known in advanced, you're can use d b's way which is have 2 different tables, 1 for display but all the data is no output, the other output only for data export and visibility hidden.
If you need to do "No Output" dynamically, then that is pretty much impossible as a limitation of SSRS.
Put this script under Visibility property.
=IIF(Globals!RenderFormat.Name = "CSV", True, False)
or Just this
=Globals!RenderFormat.Name = "CSV"
It is not possible to conditionally hide a field for CSV output in SSRS.
But if it is very important to you, you can go through the trouble of creating 2 (or more) nearly-identical tables and show/hide the entire tables conditionally.
The contents of hidden tables (as opposed to rows and cells) do not get exported to CSV.
=IIF(Globals!RenderFormat.Name = "CSV", True, False)
This doesn't work.
The only option is to create as many reports with the different column combinations then load the correct one dynamically.

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.

Formatting of exported SSRS report to CSV file

My 2008R2 SSRS report contains a detail column called debit which is formatted like "#,0.00". When I export the file via .csv the debit column does not always have the right formatting of 0.00. If the number is 0, then what appears is "0". If the number is 123.40, then it appears as 123.4. If the number is 123.44, then it appears as 1213.44.
I want each number in this column to always have 2 decimal places in the .csv file. I checked out many other articles on stackoverflow about this, but none seem to address this issue correctly.
I tried changing the format to many other formats. I noticed when I changed the format in SSRS to "C" for currency, then the 2 decimal places appeared. But the problem with that is my users do not want the "$" symbol.
I tried changing the CSV export to ASCII format in the config file, but that did not work.
I used the code here:Non-Unicode CSV Export from SQL Server Report Server
Can anyone help me with getting the format correct in the CSV file without mannually changing the CSV file?
Thank you!
The problem mentioned is report header's are being displayed when user generate report for CSV format, which is not supposed to be like that. But actually in CSV Format, While in the preview , we can hide or show report header's and it doesn't show textbox names .
While in the exported/generated one , the CSV format hides the report's headers, but instead of that it shows textbox names and any changes We made in the properties to change that textbox name to make it as blank or disappear, it reflects on that column values but doesn't on that textbox name.
So I want to mention that better We can give some other meaningful names or by default it shows as 'Textbox1', but we must give any valid name to that textbox name and it appears on the generated CSV format.
NOTE: I also want to mention that all visibility properties works well with the report header's but not on the textbox names.

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.