dynamic columns
Hi, I am Narendra working on reporting services I am facing problem in report design can u please provide me the solution to the follwing problem i need to prepare the report which is of dynamic(don't know how many columns my query returns) not static in nature I cannot make columns hide/visible with visiblity expression Is it possible to create this type of report with ssrs? will writing custom code help me in any way? Please suggest me the solution Thanks and regards, Naren
June 27th, 2012 3:16pm

Hi, You can first Create the dataset with some default parameters, so some fields will be created. Now, you need manually add all other possible fields (columns) into dataset. Now, you can use IsMissing property of each filed to check whether this field is returned or not and based on this you can show\hide the columns in tablix. Kindly have a look at below post to get info https://sqlserverbiblog.wordpress.com/2010/03/11/dynamically-adding-and-removing-columns-to-a-query-and-report-2/- Chintak (My Blog)
Free Windows Admin Tool Kit Click here and download it now
June 27th, 2012 3:27pm

Hi Narendra, From your description, you need dynamic columns in your report, right? In this case, we can create a parameter to achieve it. So the dataset can be changed according to the parameters that users select. The steps below are for you reference: 1. Create a parameter in your report, in my test report I create a parameter named CalendarYear, and [CalendarYear] is a column name of my table. 2. Add a Filters like below to dataset: Expression: [CalendarYear] Operator : In Value : [@CalendarYear] Or you can Add a condition in your query like below: where CalendarYear in(@CalendarYear) If you have any questions, please feel free to ask. Regards, Charlie Liao
July 1st, 2012 9:29pm

Hi Charlie Thanks for your posting. I dont know whether I have misunderstood the question or not, but what I read from the question that Narendra would like to add column at runtime (that dynamically updates report definition files) I might be wrong but this is what I understand. The link provided by Chintak is a workaround but in this case you have to know in advance how many columns you have inside your Report, you could not change the report definition files at run time, you can just hide/show the based on expression As far as I know you need to manually update the field list if you want to add a column to it. Whether you do it by hand, or by writing custom code you have to do it yourself - there is nothing out of the box in SSRS that dynamically updates report definition files for you. I will look forward to hear for your response Many thanks Syed Qazafi Anjum
Free Windows Admin Tool Kit Click here and download it now
July 1st, 2012 9:48pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics