Solved

SSRS Dynamic Column Names

Posted on 2016-08-03
3
51 Views
Last Modified: 2016-09-04
I am creating a report where the SP returns a fixed set amount of columns although the column names are dynamic. Is there a way to have the report pick up on this and use the dynamic names, each time the report is run?
0
Comment
Question by:thinklings
  • 2
3 Comments
 
LVL 22

Accepted Solution

by:
Nico Bontenbal earned 500 total points
ID: 41744007
Probably not. You options are very limited. Only if the range of possible column names is limited you could work around this limitation of SSRS. See the sample I've attached. The query returns the current seconds of the current time. The filed name is in the format 'fldx' where x is 0 to 5 depending on the first digit of the seconds. So if the current time is 11:49:34 the value is 34 and the fieldname is fld3. That gives me a Dataset with a dynamic column but I know the column will be fld0 to fld5. Also the Dataset has the column 'columnname' that returns the name of the column so I can use this to hide or show columns in my report. I also had to add all the possible column names manually to my Dataset. Then I can use this to show the value of the dynamic column:
=Fields(Fields!columnname.Value).Value

Open in new window


This result in a report that shows only the column that is actually returned by the query. But if they are the top 10 of your 50.000+ product list for example, this is not going to work.

See this blog post for another workaround:
http://sonalimendis.blogspot.nl/2011/07/dynamic-column-rdls.html

The best way to solve this is probably to adapt your query to have fixed column with dynamic data and then use that data to create a matix with dynamic columns.
DynamicColumn.rdl
0
 
LVL 45

Expert Comment

by:Vitor Montalvão
ID: 41744010
Maybe using a dynamic dataset?
0
 
LVL 22

Expert Comment

by:Nico Bontenbal
ID: 41744028
@Vitor Didn't you read the question, the article you link to, or both?
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Via a live example, show how to shrink a transaction log file down to a reasonable size.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now