Show or hide column in a subreport based on main report's input paramater

Jahnavi Sriram 1 Reputation point
2022-03-31T15:11:48.347+00:00

Hi,

I have a report which takes input parameters from drop down and then I have a subreport which shows up when user selects a particular value from paramater drop down in the main report.

Now, my requirement is, I have to create another input paramater in the main report which has values "yes" and "no".
If a user selects "Yes" , then it should show up a column from subreport , oherwise hide this particular column.

How do we show or hide a column in subreport based on main report's input paramater?

Any help would be appreciated.

Thanks in advance

SQL Server Reporting Services
SQL Server Reporting Services
A SQL Server technology that supports the creation, management, and delivery of both traditional, paper-oriented reports and interactive, web-based reports.
2,913 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Joyzhao-MSFT 15,576 Reputation points
    2022-04-01T04:16:14.383+00:00

    Hi @Jahnavi Sriram ,
    As you said, the subreport works fine for now.
    If you add a new parameter [OR] based on the existing main report, the parameter values are "Yes" and "No", and the settings are as follows:

    189032-image.png

    188937-image.png

    Similarly, set this parameter in your subreport, and the operation is the same as above. In my case, when the parameter selection is "Yes", the column [Month] is displayed, otherwise it is not displayed. The expression to set the visibility of this column is as follows: =IIF(Parameters!OR.Value="Yes",False,True)

    188964-image.png

    Switch to the main report, select the subreport, and set Subreport Properties. The second parameter is the parameter created above for hiding/showing subreport columns. In the drop-down list of [Name], select the parameter of the subreport (parameter [OR] in my case), and select the expression in [Value]: =Parameters!OR.Value(This is the value that the main report needs to pass to the subreport.)
    As shown below:
    188930-image.png

    Now you can run your main report, when the second parameter [OR] is "Yes", the column [Month] will be displayed; when the second parameter [OR] is "No", the column [Month] will not be displayed .
    Preview:
    189041-image.png
    189033-image.png
    Best Regards,
    Joy


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.