Adding Header Group to Crosstab

(12 posts) (4 voices)
  1. nsepetys, Member

    Hi myDBR Representative,

    I understand the use case might seem odd but I have data that needs the crosstab command and a series of five groupings that I would like to group under this. If I do the cross tab and command it seems the command does not work- which makes sense because normally the groupings are either done with vertical data (crosstab) or horizontal data (, not both. I can easily insert a table row after the html generates but short of doing some javascript I don't seem to think there's an easy work around. Do you guys have any ideas using the myDBR framework, as is?

    - Noah

  2. myDBR Team, Key Master

    do you have an example of the result you are trying to accomplish? It's bit hard to quess without further clarification.

    myDBR Team

  3. nsepetys, Member

    It's like if I inserted a header grouping for the crosstabbed columns. See example from here below:
    select 'dbr.crosstab', 'Period'; select 'dbr.sum', 'last', 'this', 'next'; select 'dbr.hsum', 'last', 'this', 'next'; select 'dbr.crosstab.title', 'Total H1'; select 'dbr.summary.text', 'area','Total'; select '','Year Group', 'this','next'; -- added portion here

    select RepArea as 'Reporting area[area]', Period, last_year as 'Last year[last]', this_year as 'This year[this]', next_year as 'Next year[next]' from mydb.ProductionSummary;

    The arrow is where I'd expect to see the header group row inserted "Year Group" for the "This Year" and "Next Year" columns (obviously directly above the "This Year" and "Next Year" columns).

  4. myDBR Team, Key Master

    So you just want to add additional header row without changing the actual crosstab format? You can do that in JavaScript as this is quite specific feature.

    myDBR Team

  5. nsepetys, Member

    Yep. I figured. It was worth asking. Thanks

  6. ajdjackson, Member


    I could do with a bit of help similar to above.

    I have the crosstab working ok but I would like to add an additional header row :

    The row I would like to add is the one below the NRx and TRx that is the Volume - Share which both span 3 columns each.

    (the addition row with % Volume Change Share Change I can live without).

    I've been playing around with javascript but getting nowhere.

    Any help would be appreciated



  7. myDBR Team, Key Master

    You would have to use JavaScript to add additional headers. Depending on how dynamic your crosstable is (variable number of repeating data sets), it may require some calculating.

    The image looks like an Excel screenshot. Not sure how your actual crosstab looks like.

    myDBR Team

  8. ajdjackson, Member


    Thanks for getting back.

    Yes you're right - the image is of an Excel spreadsheet I'm trying to mimic.

    My one looks like this

    There will only be 2 repeating datasets - NRx and TRx.

    I'm looking to add the row below the row that has the NRx and TRx groupings ie the 2nd row and the added row will have 2 headings Volume and Share each spanning across the 3 data columns each.



  9. myDBR Team, Key Master

    You would have to add rowspan to the first rows first TH element to make room for new row and add the new row as third row with Volume and Share columns (2x with colspan 3).

    myDBR Team

  10. ajdjackson, Member


    Thanks for the tip ie increasing the rowspan.

    I managed to do it :)

    $('table.execsum tr th.cell_ct_top.align_c[rowspan=2]').attr('rowspan',3);

    $('table.execsum thead tr:nth-child(2)').after('<tr class=\"row_header\"><th class=\"cell_ct ct_col align_c\" colspan=\"3\">Volume</th><th class=\"cell_ct ct_col align_c\" colspan=\"3\">Share</th><th class=\"cell_ct ct_col align_c\" colspan=\"3\">Volume</th><th class=\"cell_ct ct_col align_c\" colspan=\"3\">Share</th></tr>');



  11. shery, Member


    dbr.sum isn't working in this case. Please advise.

  12. myDBR Team, Key Master

    your JavaScript looks ok. One question: do you always have fixed crosstab columns NRx and TRx or can they vary?

    What does it mean when you say "dbr.sum isn't working"? Do you get an error or an unexpected result? Adding a header row should not affect the dbr.sum.

    The best way to send a question is to get a SQL Export of the report and send the SQL file with the explanation of the expected result to the support email. This way we can rerun the report without your tables/data.

    myDBR Team


You must log in to post.