Generate dynamic columns in t:dataTable

Hi ,
Can anybody please give me an example of generating column dynamically in a t:dataTable. My requirement is i have a list of checkboxes in a popup for different company account IDs. when i click on any of those checkboxes and click View Button on the same popup the popup should be closed and the a new column should appear in the dataTable with the header as Company Account and colum values must include checkboxes. Please provide me with some direction as how to achieve this task
Appreciate your help in advance.

check myfaces tomahawk exemple , there is a t:columns exemple inside :
[http://www.apache.org/dyn/closer.cgi/myfaces/binaries/tomahawk-examples-1.1.9-bin.zip|http://www.apache.org/dyn/closer.cgi/myfaces/binaries/tomahawk-examples-1.1.9-bin.zip]

Similar Messages

  • Generating dynamic column in planning layout

    Hi Guys,
    I am new to BPS.. My task is user inputs calendar year thru variable, based on the year it has generate dynamic columns as month of the year entered by the user.
    Dnt know i am right or wrong based on the sdn threads. i think i have to create user input variable, and create a FM to read the user input value. Upto to this i can understand, after reading the user input how to calculate the months and generate 12 columns dynamically for each month...
    Kindly help me in this scenario..
    Edited by: kevin peterson on Jun 6, 2008 5:23 AM

    Hi,
    I hope you are using calendar year/month and calendar year characteristics. Create an user input variable for calendar year,
    create one exit variable for calendar year month.
    Inside this exit, read the value of the user input variable, append the year with all 12 months, so u get 12values for this exit variable.
    Now keep calendar year in header, restricted by user input variable, create one data column dynamic for calendar year month restricted by this exit variable. This will generate 12columns dynamically.
    Bindu

  • Generating dynamic columns for a report

    Hi all,
          Can anybody pls. tell me how to output dynamic columns in a report. my req. is that i've to generate so many columns as there are no. of unique(a particular field value) rows in my internal table. for e.g say suppose i've 5 rows in my internal table which has 2 fields, one short text & it's corresponding value. so now my report output shud have 5 columns with the short text as the column heading & the their corresponding values below each column heading. i heard it can be done thru field-symbols. can anyone pls. guide me.

    Hi Sushma,
    This piece of code might be useful.
    The following sections will help you to understand the steps required to define a Dynamic ALV.
    Following symbol signifies:
    Þ                    Important
    Main Steps Required
    The following are the main steps that are to be performed for defining a dynamic Alv
    1.       Defining a field catalog
    2.       Defining the dynamic table
    3.       Filling data into the table
    4.       Displaying ALV list
    Defining a field catalog
    The purpose of defining a field catalog first in case of Dynamic ALV is somewhat different than in case of normal ALV. In case of Dynamic ALV the field catalog is used to define the final internal table that will hold the data, and would be used to display the final output.
    Þ It is very important to remember that the field catalog table be refreshed first, else it might give an error.
    For example:
    DATA: T_FIELDCAT TYPE LVC_T_FCAT,
    L_FIELDCAT TYPE LVC_S_FCAT.
       Refresh T_FIELDCAT.
      CLEAR L_FIELDCAT.
      L_FIELDCAT-FIELDNAME = 'LIFNR'.
      L_FIELDCAT-INTTYPE = ''.
      L_FIELDCAT-OUTPUTLEN  = 10.
      L_FIELDCAT-COLTEXT  = TEXT-002.
      APPEND L_FIELDCAT TO T_FIELDCAT.
    Defining the dynamic table.
    This table will hold the final data that needs to be displayed. To declare the table the following things need to be done.
    Declare a field symbol
    Displaying Alv List
    This is done in the same way as we do for normal Alv. Call function “REUSE_ALV_GRID_DISPLAY” and pass the field catalog table in the export parameters and the dynamic table in Tables.
    Reward Points if it is helpful.
    Reagrds,
    Kiran I

  • How to Generate Dynamic Columns from SQL

    Hi Friends,
    I want to create a data fromat like This
    Showroom / date    01-01-09        02-01-09     03-01-09     04-01-09      05-01-09     06-01-09     07-01-09   
    S1                           20                      10              09            90             90                  10            100
    S2                           10                       1                1              2               6                    2             10
    S3                            5                        7                 9             1               2                    3             12This Data is Just like Matriz Reports....................................
    Here i Want to Generate Date column value Dynamically.....................is it possible through SQL
    the values are Sales value for each showroom for diffrent date value
    all sale,showroom and Date Column are in one Table......................
    It should Generate date Dynamically depending on User VAlues./..............
    Thanks in Advance

    something to play with (not tested as I don't have database access)
    declare
    /* assuming table showroom_sales has columns a_showroom,a_date,a_sale */
      the_sql varchar2(32000) := 'select a_showroom';
      day_from date := to_date('20090101','yyyymmdd');
      day_till date := to_date('20090107','yyyymmdd');
    begin
      for d in (select a_date from showroom_sales where a_date between day_from and day_till)
      loop
        the_sql := the_sql ||
                   ',max(decode(a_date,to_date('''||to_char(d.a_date,'yyyymmdd')||''',''yyyymmdd''),a_sale,null)) "'||to_char(d.a_date,'dd-mm-rr')||'"'
      end loop;
      the_sql := the_sql || ' from showroom_sales group by a_showroom order by a_showroom ';
      dbms_output.put_line(the_sql);  /* to verify if query is correct or not */
    end;the code above should generate something like (provided all those dates appear in your showroom_sales table)
    select a_showroom,
           max(decode(a_date,to_date('20090101','yyyymmdd'),a_sale,null)) "01-01-09",
           max(decode(a_date,to_date('20090102','yyyymmdd'),a_sale,null)) "02-01-09",
           max(decode(a_date,to_date('20090103','yyyymmdd'),a_sale,null)) "03-01-09",
           max(decode(a_date,to_date('20090104','yyyymmdd'),a_sale,null)) "04-01-09",
           max(decode(a_date,to_date('20090105','yyyymmdd'),a_sale,null)) "05-01-09",
           max(decode(a_date,to_date('20090106','yyyymmdd'),a_sale,null)) "06-01-09",
           max(decode(a_date,to_date('20090107','yyyymmdd'),a_sale,null)) "07-01-09"
      from showroom_sales
    group by a_showroom
    order by a_showroom to be executed to get the result as required
    Regards
    Etbin

  • Generate dynamic column

    Hi masters,
    i am new in Abap devlopment.
    i'hv a problem
    three record is in the itab like
    matnr   bwart  menge
    m1       101     25
    m1       312    12
    m2        311    20
    and i want to show like this
    matnr    101    311   312
    m1         25     0       12
    m2         0       20      0
    but bwart are not fix, so column would be dynamic.
    please help me..
    thanks in advance.

    Hi Amit,
      I think this can be achived by creating internal table dynamicaly,
    May be on runtime you will come to know how many fields are there,
    So create a fieldcatalog of the fields to be display,
    then use Method cl_alv_table_create=>create_dynamic_table to create the internal table dynamically.
    wa_fcat-fieldname = 'MATNR'.
    append wa_fcat to t_fcat.
    loop at it_sizes.
    wa_fcat-fieldname = it_sizes-size.
    append wa_fcat to t_fcat.
    endloop.
    cl_alv_table_create=>create_dynamic_table
    EXPORTING
          it_fieldcatalog  = t_fcat
          i_length_in_byte = 'X'
    IMPORTING
          ep_table         = dy_table.
      ASSIGN dy_table->* TO <dyn_table>.
    I think this will help you.
    check the wiki for creating dynamic internal table
    [http://wiki.sdn.sap.com/wiki/display/ABAP/DynamicInternaltable]
    Thanks,
    Anmol.

  • Dynamic Column in PDF

    Hello All,
    I have a requirement to generate dynamic column in the PDF.
    I have got the same running using the below code
    HEADER : <?split-column-header:XXX_TIME?><?split-column-width:@width?><?XXX_TIME_FROM?>
    DATA : <?split-column-data:XXX_START?><?EMP_NO?>
    The issue I am having is if i generate the output in pdf with small amount of data,it will work but I am not sure how much data can come at run time.
    It can be sometime more than 50 or more columns also.In that case it truncates the data.
    How can i do the same.
    Pls help.
    Thanks
    Sk

    Increase the page size and printable page size, and reduce the column lengths,
    so that you can accomadate them in single row.
    BIP will run in single row, but we have option of making it to next row too.
    But even if you make it in single row, page size has to support the length of the single row you are making :)..
    so you got to increase the page width to Max

  • DataTable with dynamic columns

    Does somebody have an example of how to code a h:dataTable with dynamic columns? I have seen hints about how to do it in these two articles:
    http://forum.java.sun.com/thread.jspa?forumID=427&threadID=5218508
    http://forum.java.sun.com/thread.jspa?threadID=577589&messageID=2909047
    but a complete working example would be really helpful.
    I think the key is understanding the "binding" parameter to h:dataTable but I'm having a hard time understanding it. Thanks.

    I found it here:
    http://balusc.blogspot.com/2006/06/using-datatables.html#PopulateDatatable

  • Dynamically generate the Column header

    Hi friends,
    I am using Binary Cache method for Export to Excel. I am using a separate method for generating the column headers. My question is : Is there a way to put the attribute names from the node directly instead of the one I am currently using.
      public java.util.Map getOrderColumnInfos( )
        //@@begin getOrderColumnInfos()
              //     Returns Header for the Table to be passed on to method toExcel()
              Map columnInfosMap = new LinkedHashMap();          
    columnInfosMap.put(
                   IPrivateABC.ISearchResultstoExcelElement.ATTRIBUTE1,
                   "Name");
              columnInfosMap.put(
                   IPrivateABCSearchResultstoExcelElement.ATTRIBUTE2,
                   "Reference");
              columnInfosMap.put(
                   IPrivateABC.ISearchResultstoExcelElement.ATTRIBUTE3,
                   "Created By");
              columnInfosMap.put(
                   IPrivateABC.ISearchResultstoExcelElement.ATTRIBUTE4,
                   "Input Date");
              return columnInfosMap;
        //@@end
    Instead of putting the header texts, I want the attribute names to be displayed on the Excel file headers. Please let me know if this is possible.

    Hello Rasim,
    The idea was to create the Column headers dynamically. This means basically at runtime the Application would recognize what is there in the screen and use it for Column headers. This involved reading the from the View Table->The Table Column Element-> The header and saving those values in a Context. This context is then mapped to the Excel Custom Controller and then all we have to do is read from the context, Convert to XML (The usual way that is.... )
    And ...There it is....!!!!
    Bit hectic to code this than the obvious Map and stuff. But it saves a lot of headache for future additions/deletions of columns to the table.
    Sample Code :
      public void populateExcelColumnsFromView( java.lang.String tableName, com.sap.tc.webdynpro.progmodel.api.IWDView view )
        //@@begin populateExcelColumnsFromView()
              //Created By : AVIK SANYAL Date : 28 March 2008
              //This method will fetch the header names from the Table in the View and set the
              // Attributes in nodeExcelTableColumns(). These nodes are mapped to
              //Excel Custom Controller and hence used to set the Column headers for the Excel File.
              IWDTable searchTable = (IWDTable) view.getElement(tableName);
              wdContext.nodeExcelTableColumns().invalidate();
              String tableDataSource = searchTable.bindingOfDataSource();
              wdContext.currentContextElement().setDataSource(tableDataSource);
              for (int i = 0; i < searchTable.numberOfGroupedColumns(); i++) {
                   //               Read the Column
                   IWDTableColumn col =
                        (IWDTableColumn) searchTable.getGroupedColumn(i);
                   IWDTableCellEditor TCE = col.getTableCellEditor();
                   IWDCaption header = col.getHeader();
                   //               This will check if the column is visible in the View only then it will
                   //               go for further processing.
                   if (WDVisibility.VISIBLE.equals(col.getVisible())) {
                        IExcelTableColumnsElement columnElement =
                             wdContext
                                  .nodeExcelTableColumns()
                                  .createExcelTableColumnsElement();
                        //               If the header is not null then set the header as in the View
                        if (header != null) {
                             columnElement.setHeading(header.getText());
                        } else {
                        //               Add the column name to the nodeExcelTableColumns()
                        //This checks the type of column in the View and then take the value.
                        if (TCE != null) {
                             if (TCE instanceof IWDTextView) {
                                  IWDTextView element = (IWDTextView) TCE;
                                  columnElement.setBinding(element.bindingOfText());
                                  wdContext.nodeExcelTableColumns().addElement(
                                       columnElement);
        //@@end

  • Dynamic columns in datatable...

    Hi guys,
    i've a question about datatable.
    I have to use datatable for inserting data into db.
    My question is:
    I'm developed a datatable with 5 columns and various rows,i've create an actionlistener and when i click it each row is successfully inserted.
    Now i want adding some columns to datatable depending by a number inserted by user.
    That is:
    the user inserts 3(for example) and the user sees in another page
    the datatable with the 5 fixed columns and others 3 columns...
    Clicking the actionListener i want the 5 columns values were inserted in a table(and it's easy) and the others variable column's number were inserted as different row in another table...
    excuse me for my english....i try an example....
    This can be one row
    giuseppe napoli milano italia europa ---variable(age address sex)----i want giuseppe napoli milano italia europa is inserted as a row in user table and age,address,sex are inserted as different rows into details table....
    i want knowing how ciclying among dynamic different columns values and inserting each value as a different row....
    thanks very much,please help me with code or ideas...

    thanks...
    but my problem is this:
    i've create a populate method that has to add dynamic column,i've supposed a fixed value,3, to my existing datatable.
    public HtmlDataTable populateMyDataTable() throws Exception{
              getBiosampleDataTable();
              for (int i=0;i<2;i++){
                   //UIOutput header = new UIOutput();
                //header.setValue(headers);
    // Set output.
    UIInput output = new UIInput();
    ValueBinding biosampleItem =
    FacesContext
    .getCurrentInstance()
    .getApplication()
    .createValueBinding("#{biosampleItem[" + i + "]}");
    output.setValueBinding("value", biosampleItem);
    // Set column.
    UIColumn column = new UIColumn();
    //column.setHeader(header);
    column.getChildren().add(output);
    // Add column.
    biosampleDataTable.getChildren().add(column);
    setBiosampleDataTable(biosampleDataTable);
              return biosampleDataTable;
    i've
    public HtmlDataTable getBiosampleDataTable() throws Exception {
              loadBiosamples();
              return populateMyDataTable();
         }and
    public void loadBiosamples() throws Exception {
              if (load==0){
              for (int i = 0; i < nrows; i++) {
                   Biosample biosample = new Biosample();
                   biosamples.add(biosample);
                   setBiosamples(biosamples);
                   load=1;
              else
                   setBiosamples(biosamples);
         where is my error?
    I'vejavax.faces.el.EvaluationException: javax.faces.el.EvaluationException: Exception getting value of property biosampleDataTable of base of type : giu.BiosamplesTableand i'm not sure about my code...can you help me?

  • How to generate a dynamic column with unique value in AMDP

    Hi Collegue,
    For AMDP I have a table with material plant,i have to assign a unique number to each unique combination of material,plants into a dynamic column say sequence.
    Please suggest me how to proceed.
    Regards,
    Saurabh

    hi
    Firstly, have a look at the following code to see how this can be implemented -
    REPORT ZTEST.
    perform test.
    class test definition.
      public section.
        methods: create_screen.
    endclass.
    class test implementation.
      method create_screen.
        data:  report_line(72),
               report_source like table of report_line.
        data: err_message(240),
              err_line type i,
              err_word(100).
        report_line = 'REPORT TEST.'.
        append report_line to report_source.
        report_line = 'PARAMETERS: P_TEST TYPE I.'.
        append report_line to report_source.
        report_line = 'START-OF-SELECTION.'.
        append report_line to report_source.
        report_line = 'WRITE : P_TEST.'.
        append report_line to report_source.
        syntax-check for report_source message err_message
                                       line    err_line
                                       word    err_word.
        if err_message is initial.
          INSERT REPORT 'ZZZTESTZZZ' FROM REPORT_SOURCE.
          SUBMIT ZZZTESTZZZ VIA SELECTION-SCREEN AND RETURN.
        endif.
      endmethod.
    endclass.
    form test.
      data test type ref to test.
      CREATE OBJECT TEST.
      call method test->create_screen.
    endform.
    As you can see, the report is being written dynamically. Once the INSERT REPORT statement is executed, the program is available. you can you external subroutine calls to pass the data between the programs now.
    Regards,
    ravish
    <b>plz dont forget to reward points if helpful</b>

  • Generating dynamic command links in data table

    Hi,
    I have a requirement to generate dynamic number of columns in a datatable. Also these columns should contain a command link.
    I have written following piece of code to do so...
    public UIData getDataTableBinding()
         UICommand comm = null;
         UIColumn col;
         UIOutput out = null;
         Application app = app = FacesContext.getCurrentInstance().getApplication();
    // Suppose I want to generate 7 columns
         for(int j = 0; j < 7; ++j) {
         out = new UIOutput();
         col = new UIColumn();
         comm = new UICommand();
         ValueBinding vb = app.createValueBinding("#{" + j + "}");
         out.setValueBinding("value", vb);
         out.setRendererType("javax.faces.Text");
         comm.setRendererType("javax.faces.Link");
    comm.getChildren().add(out);
         MethodBinding mbButton = app.createMethodBinding("#{pc_File1.doLink1Action}",
    null);
         comm.setAction(mbButton);
         col.getChildren().add(comm);
         dataTableTemp.getChildren().add(col);
         return dataTableTemp;
    I have bound the "binding" attribute of the data table to getDataTableBinding()
    method.
    If I remove all the references to UICommand i.e comm variable, table is displayed properly, but if
    I try to include a command link component as mentioned above I get "Assertion failed error"
    SRVE0068E: Could not invoke the service() method on servlet Faces Servlet. Exception thrown :
    javax.servlet.ServletException: javax.faces.el.EvaluationException: Error getting property
    'dataTableBinding' from bean of type pagecode.File1: javax.faces.FacesException: Assertion Failed
         at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:638)
         at com.ibm._jsp._File1._jspService(_File1.java:92)
         at com.ibm.ws.jsp.runtime.HttpJspBase.service(HttpJspBase.java:88)
    Any kind of help on this issue would be appreciated,
    Thanks in advance,
    Raina

    Hi,
    I solved my problem just by replacing UIOutput component with HtmlOutputText component and then making it as a child component of UICommand component.
    Now I am facing a new problem. Whenever I try to refresh the page I get following exception
    "SRVE0026E: [Servlet Error]-[Faces Servlet]: java.lang.IllegalStateException: Duplicate component ID 'form1:table1:cmd0' found in view."
    I am explicitly setting the component id of the UICommand component using the setViewId() method.
    This problem is observed only when I refresh the page. In case I navigate to another page and then again come back to this current page, then I don't get this exception.
    Your help would be appreciated,
    Raina

  • Dynamic column names in Oracle

    HI SOS!! calling for help...
    i am trying to query the following. I want to remove the duplicates in the ID, and combine them into one... While doing so, I want to keep the data as it is by creating dynamic columns reason_1, reason_2, reason_3 with their corresponding TIME. In case of same reasons, I want to add the TIME. The database is as follows:
    ID     REASON     TIME
    A     41A..........     27
    A     93K..........16
    B     89C...........3
    B     93K...........7
    B     48C..........     4
    C     93K..........     24
    C     93K..........     7
    C     48C.........10
    Expected Result is
    ID     REASON_1......TIME_1.... REASON_2...TIME_2....REASON_3.........TIME_3
    A........ 41A............ 27........... 93K............16          
    B........ 89C............ 3............ 93K............7...........48C.................. 4
    C........ 93K........... 31.......... 48C..............10          
    Would be grateful if someone could try helping me out of this as early as possible.
    Edited by: 968125 on Oct 28, 2012 11:01 PM

    You still haven't made it clear what the requirement is.
    Is there a maximum number of reasons that can occur per ID? If so, you can code the pivoting of your data with something like:
    SQL> ed
    Wrote file afiedt.buf
      1  with t as (select 'A' as ID, '41A' as reason, 27 as time from dual union all
      2             select 'A', '93K', 16 from dual union all
      3             select 'B', '89C', 3 from dual union all
      4             select 'B', '93K', 7 from dual union all
      5             select 'B', '48C', 4 from dual union all
      6             select 'C', '93K', 24 from dual union all
      7             select 'C', '93K', 7 from dual union all
      8             select 'C', '48C', 10 from dual)
      9  --
    10  -- END OF TEST DATA TABLE SIMULATED USING 'WITH' CLAUSE
    11  -- SIMPLY USE THE SELECT STATEMENT BELOW ON YOUR OWN TABLE
    12  --
    13  select id
    14        ,max(decode(rn,1,reason)) as reason_1
    15        ,max(decode(rn,1,time)) as time_1
    16        ,max(decode(rn,2,reason)) as reason_2
    17        ,max(decode(rn,2,time)) as time_2
    18        ,max(decode(rn,3,reason)) as reason_3
    19        ,max(decode(rn,3,time)) as time_3
    20        ,max(decode(rn,4,reason)) as reason_4
    21        ,max(decode(rn,4,time)) as time_4
    22        ,max(decode(rn,5,reason)) as reason_5
    23        ,max(decode(rn,5,time)) as time_5
    24  from (/* assign some row numbers within each ID, ordering by 'reason' then 'time' */
    25        select id, reason, time
    26              ,row_number() over (partition by id order by reason, time) as rn
    27        from   t
    28       )
    29* group by id
    SQL> /
    I REA     TIME_1 REA     TIME_2 REA     TIME_3 REA     TIME_4 REA     TIME_5
    A 41A         27 93K         16
    B 48C          4 89C          3 93K          7
    C 48C         10 93K          7 93K         24In this example, it will cater for up to 5 reasons/times per ID... and you can code for more if you need very easily.
    Also, as you're using 11g, you can use the new PIVOT query, for which you can find plenty of examples if you google or search these forums, or follow the FAQ link.
    If you don't have any idea how many reasons there could be, then you really are looking at generating columns dynamically.
    The problem with that is, because Oracle needs to know the SQL projection (see the FAQ link already provided), it has to know how many columns are going to be returned from a query before any data is fetched... but you are saying that the columns returned have to be based on the data itself. To do that you have two main options:
    1) You query the data once to determine how many columns you are going to need and then dynamically build up a query in PL/SQL code with the right number of columns (or use one of the other dynamic methods shown in the FAQ)
    or
    2) You step back and ask yourself if SQL is really the best place to be trying to produce this output. Reporting tools are often better suited to this requirement as they are made to query the data back from a database and then pivot and layout the data based on the data returned.

  • How to add  dynamic column  in jfreereport

    hi,
    i am working on a project aboit accounting package.
    i had created a report in jfreereport .. buti am facing the problem of dynamic column addition in that..
    i have to create the number of column as per user given range that will from 2 to 365
    i had generated column for that
    that should be like
    1 - 5 , 6 -10 , 11 - 15 , etc...
    how can i represent that alll column in print preview i can't represent that report in horizontal fashion . is there any way to display it ..
    this report has no bound in horizontal or verticle means i have any number of rows or columns..
    pls help.
    kamlesh

    hi,
    that means u have fixed columns right? ie 5 columns in a report
    if it write, than u can find out how u can rename the columns with exiting
    one.
    that means while runing report u have to pass all the 5 columns to report
    instead of the exiting columns (ie rename the columns that u want add
    columns)
    u have to search in code for renaming in the code ie jfreereport package.
    i think u understood.
    daya

  • Dynamic column name

    hi experts,
      DATA: temp(20) VALUE 'DATA',
            i TYPE I VALUE 1,
            J(2) type c.
            LOOP AT l_t_tsi.
                     J = I.
                    CONCATENATE TEMP J INTO COLNAME.
                    itab-(COLNAME) = l_t_tsi-time_series_value.
                    i = i + 1.
          ENDLOOP.
    My internal table (itab) has fields data1(20), data2(20), data3(20)...
    I want to generate the column names dynamically only.
    The above code gives an error at this line -
                    itab-(COLNAME) = l_t_tsi-time_series_value.
    Thanks in advance,
    Bijal

    Hi,
    If your aim is to refer to a internal table field dynamically you can do it.
    Look at the code segment below -
    DATA: temp(20) VALUE 'DATA',
    i TYPE I VALUE 1,
    J(2) type c.
    FIELD-SYMBOLS: <ls_data>.
    LOOP AT l_t_tsi.
    J = I.
    CONCATENATE TEMP J INTO COLNAME.
    <b>ASSIGN COMPONENT colname OF itab TO <ls_data>.
    <ls_data> = l_t_tsi-time_series_value.</b>
    *itab-(COLNAME) = l_t_tsi-time_series_value.
    i = i + 1.
    ENDLOOP.
    Regards,
    Manish Joshi
    If it solves your problem, close the thread.
    Don't clutter-up forum by leaving open threads.

  • Pivot Table with Dynamic Columns and Headers

    Hello,
    I'm trying to pivot a table of data where the column headers will be dynamic.  While I know how to pivot the table to get what I want how will I be able to pick up the table column header from the Pivot to display in the report?
    For example:
    Unpivoted data is Employee Code, Branch Code, Problem Code, # of Problems.
    There is many records for a given Employee and Branch that I want to pivot so the Column headers are the Problem Codes and the data below is the SUM(num_problems) for that Problem.
    So the data may look like this for Tech Bob, Branch NY.
    Problem = LEAK, Num_problem = 5
    Problem = DAMAGE, Num_problem = 2
    Problem = OTHER, Num_problem = 3
    Which problem codes may appear is unknown but selecting the DISTINCT(problem) across all techs gives me the column headings to use.
    So if I pivot this data, I get this Row:
    Tech = Bob, Branch = NY, DAMAGE = 2, LEAK = 5, OTHER = 3
    So first can SSRS handle having dynamic columns?  Only Tech and Branch are known and the remaining columns are dynamic based on how many Problems they worked on.
    Second, how can I set the column heading in my Tablix to be the Problem Code?
    Sherry

    You just need to use a  matrix container
    Use EmployeeCode and BranchCode for row group
    ProblemCode as column group and SUM([No Of Problems]) as the data expression and it will generate the columns for you based on ProblemCode values automatically.
    See an example here
    Sample Matrix
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My MSDN Page
    My Personal Blog
    My Facebook Page

Maybe you are looking for