I have a stored procedure (which pivots and unpivots values) that runs as the backend of an SSRS report. The user provides 2 inputs (BeginRange and EndRange).
The results change according to user input and hence I need to reflect those changes on the report as well. The problem is, once I have the report done, as soon as I supply a new input, the report fails because its still bound with the old column headings. Is there anyway to change the column headings and the TextBox values dynamically?
Sample result data is something like:
The column headers will change from week to week. How do I get this ever changing report on my SSRS report?
The problem isn't quite what you think it is:
Yes, you can change the column headings and textbox values dynamically. But this won't help you.
The fields (columns) returned by your data source can not be dynamic for a SQL dataset.
You need to establish a fixed set of fields that your query will return, and then you can pivot those or select from the set of columns dynamically when displaying the report. For example, if I wanted a report to display:
June July Aug Sept Oct Nov Dec
Department A 20 25 33 36 48 29 35
Department B 22 24 30 23 40 20 33
Then I would design my query to return:
Department Month Quantity
Department A June 20
Department A July 25
Department A Aug 33
Department A Sept 36
Department A Oct 48
Department A Nov 29
Department A Dec 35
Department B June 22
...
The query results you provided will be difficult to use with SSRS: can you modify the query or create another to return fixed columns, similar to what I indicate above? At the very least, you will need to change the field names (column headers) so that they do not change from month to month: month1 month2 month3 ...