Adding Header Group to Crosstab

(10 posts) (3 voices)
  • Started 2 years ago by nsepetys
  • Latest reply from ajdjackson
  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 header.group command it seems the header.group command does not work- which makes sense because normally the groupings are either done with vertical data (crosstab) or horizontal data (header.group), 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

    Posted 2 years ago #
  2. myDBR Team, Key Master

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

    --
    myDBR Team

    Posted 2 years ago #
  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 'dbr.header.group','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).

    Posted 2 years ago #
  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

    Posted 2 years ago #
  5. nsepetys, Member

    Yep. I figured. It was worth asking. Thanks

    Posted 2 years ago #
  6. ajdjackson, Member

    Hi

    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

    Thanks

    Jake

    Posted 1 year ago #
  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

    Posted 1 year ago #
  8. ajdjackson, Member

    Hi

    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.

    Thanks

    Jake

    Posted 1 year ago #
  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

    Posted 1 year ago #
  10. ajdjackson, Member

    Hi

    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>');

    Thanks

    Jake

    Posted 1 year ago #

Reply

You must log in to post.