locked
SSRS - Display column header from dataset RRS feed

  • Question

  • My report uses a stored procedure to return a dataset.

    I want to be able to use the column name from the dataset as my column header in the Report.

    How can this be achieved?


    Sanjeev.

    Wednesday, August 8, 2012 10:50 AM

Answers

  • I've found a better way, using subreports.

    Each report having its own dataset. The dataset for the main report returns 1 row only with the actual column names, which are used for the column headers:

    Col1       Col2       Col3       Col4

    Jan-12   Feb-12   Mar-12   Apr-12

    The subreport dataset returns the actual data

    you can have a nice tutorial on subreports at this link: 

    http://www.codeproject.com/Articles/195017/SSRS-Series-Part-II-Working-with-Subreports-DrillD


    Sanjeev.

    • Proposed as answer by Charlie Liao Friday, August 10, 2012 5:29 AM
    • Marked as answer by Charlie Liao Wednesday, August 15, 2012 9:10 AM
    Thursday, August 9, 2012 7:53 AM

All replies

  • Hi,

    You can use expression in the column header textbox to fetch the max value for a column from dataset.

    Please revert if this is not the same you want.


    - Chintak (My Blog)

    Wednesday, August 8, 2012 11:01 AM
  • Hi,

    Fetching the max value for a column will return the max value from the column isn't it?

    I'm looking to display the column name from the dataset as my column header in the report.


    Sanjeev.

    Wednesday, August 8, 2012 11:09 AM
  • As far as I know, you can't access the name of a dataset field. So to be able to load your column names dynamically, the only option that I see is by adding an additional "label" field for your available columns to your dataset.  Imagine you'd have a column called Col1, you could then add an additional field called Col1Label which has "Col1" as value.

    That will allow you to make the header names dynamic.


    MCITP SQL Server 2008 (DEV); MCTS SQL Server 2008 (BI, DEV & DBA)

    • Proposed as answer by Alex Jean Wednesday, August 8, 2012 4:35 PM
    • Unproposed as answer by Alex Jean Wednesday, August 8, 2012 4:36 PM
    • Proposed as answer by Valentino Vranken Wednesday, August 8, 2012 4:39 PM
    Wednesday, August 8, 2012 1:24 PM
  • I've found a better way, using subreports.

    Each report having its own dataset. The dataset for the main report returns 1 row only with the actual column names, which are used for the column headers:

    Col1       Col2       Col3       Col4

    Jan-12   Feb-12   Mar-12   Apr-12

    The subreport dataset returns the actual data

    you can have a nice tutorial on subreports at this link: 

    http://www.codeproject.com/Articles/195017/SSRS-Series-Part-II-Working-with-Subreports-DrillD


    Sanjeev.

    • Proposed as answer by Charlie Liao Friday, August 10, 2012 5:29 AM
    • Marked as answer by Charlie Liao Wednesday, August 15, 2012 9:10 AM
    Thursday, August 9, 2012 7:53 AM
  • It depends a bit on the situation, but perhaps you don't even need to use a subreport.  Possibly you could put two tables right above each other.  The first would contain only one line displaying the header names, coming from DataSet1.  And the second table would display the data from DataSet2.

    MCITP SQL Server 2008 (DEV); MCTS SQL Server 2008 (BI, DEV & DBA)

    Thursday, August 9, 2012 8:18 AM