Reporting Services - hide table column based upon report parameter

后端 未结 8 1331
旧时难觅i
旧时难觅i 2021-01-04 13:45

I have a report in Reporting Services 2005, and I want to hide or show a single table column based upon a report parameter. Does anyone have any idea how to do that?

<
相关标签:
8条回答
  • 2021-01-04 14:06

    Let’s say my report(SSRS 2005) have 5 columns. And I want to show/ hide columns based on a parameter(multi select with all 5 column names) selected by user. do as following

    1)Create a parameter of type string (ColumnVisibility is name of my parameter) with desired column names in labels for the 5 columns and INT number(01,02,03,04,05) respectively in the values in “Available Values” section of the parameter wizard.

    2) Then Go to column Properties on design . Go to “visibility” and paste following

    =iif(instr(Join(Parameters!ColumnVisibility.Value,","),"01")>0,false,true) 
    

    3) repeat same for all the columns, by increasing the int value by 1..see following for example

    2nd column

    =iif(instr(Join(Parameters!ColumnVisibility.Value,","),"**02**")>0,false,true)
    

    3rd column

    =iif(instr(Join(Parameters!ColumnVisibility.Value,","),"**03**")>0,false,true)
    

    And so on. For SSRS 2008, when you right click on the column you can see "Column Visibility" option. paste the code in "show or hide based on an expression" section for each column.

    0 讨论(0)
  • 2021-01-04 14:11

    when I do as above, I can make the column disappear but it leaves a gap in my table. Is this the expected result. I was hoping the columns would also shift over. I'm trying to hind a column for one group and then display it for the next group.

    0 讨论(0)
  • 2021-01-04 14:18

    Set the Visibility for the column to an expression which will return true or false. This property can be found on in the Visibility tab on a TextBox for example.

    Click the radio option for Expression and then your expression might look like

    =Parameters!ShowColumn.Value
    
    0 讨论(0)
  • 2021-01-04 14:24

    Tip: If the expression returns "False" then the column or row will be visible. If the expression returns "True", the expression will be hidden. This tricked me at first.

    0 讨论(0)
  • 2021-01-04 14:25

    Use the visibility property of the column. This worked for me.

    =iif(Parameters!ParameterName.Value = "TextValueOfTheParameter",False,True)
    
    0 讨论(0)
  • 2021-01-04 14:26

    If you want to hide whole column, when there are no data at all for that specific column in the report, you can use following code in the column visibility/expression:

    =IIF(IsNothing (Sum(Fields!columnA.Value, "ReportA")),False,True)
    
    0 讨论(0)
提交回复
热议问题