Saturday, January 30, 2010

OBIEE Horizontal Pivot Sections Part 2

Based on this post: I was asked if this was possible:


Or a “carriage return” every x columns. So extra lines to Joe’s code fixed it:

    <script type="text/javascript">
    /* based orignal code by Joe Betram
    /* see:
    /* This Version John Minkjan :
    /* Thanks to Nandoo for noticing the IE bug
    /* Set the number of columns */
    var intColumnNumbers = 5;

    function insertAfter( referenceNode, newNode )
        referenceNode.parentNode.insertBefore(newNode, referenceNode.previousSibling);
    var debug =1;
    var sectioncnt =0;
    var x =0;

    if (debug === 1) { document.write("Get all tables"+"<BR>");}
    var tables = document.getElementsByTagName('table');

    if (debug === 1) { document.write("Loop over the tables"+"<BR>");}
    for(var table=0; table < tables.length; table++){

    if(tables[table].className != 'PTSectsTable' ){

    if (debug === 1) { document.write("Found a pivot table"+"<BR>");}

    var tbody = tables[table].getElementsByTagName('tbody')[0];
    if (debug === 1) { document.write("Grabbed the tbody code"+"<BR>");}

    var trs = tbody.getElementsByTagName('tr');

    var new_tr = document.createElement('tr');
    var nw_tr =new Array();
    nw_tr[x] = document.createElement('tr');
    if (debug === 1) { document.write("Created the new_tr variable"+"<BR>");}

    while( trs.length > 0){

    var new_td = document.createElement('td');
    if (debug === 1) { document.write("Created a new TD element."+"<BR>");}

    var new_table = document.createElement('table');
    if (debug === 1) { document.write("Created a new table element."+"<BR>");}

    var new_tbody = document.createElement('tbody');
    if (debug === 1) { document.write("Created a new tbody element."+"<BR>");}

    if (debug === 1) { document.write("Appended Section."+"<BR>");}

    if (debug === 1) { document.write("Appended Data."+"<BR>");}

    if (debug === 1) { document.write("Appended tbody to the table tag."+"<BR>");}

    if (debug === 1) { document.write("Appended table to the TD tag."+"<BR>");}

    if (debug === 1) { document.write("Appended td to the overall TR tag."+"<BR>");}
    sectioncnt = sectioncnt +1;
    if (debug === 1) { document.write(sectioncnt%intColumnNumbers+"<BR>");}

    if (sectioncnt%intColumnNumbers ===0){        
        var new_tr = document.createElement('tr');
        x =x+1;
    var y=0;
    for (y=0; y<nw_tr.length; y++)
    if (debug === 1) { document.write("Inserted the new_tr variable as the first child of tbody"+"<BR>");}

    if (debug === 1) { document.write("Finished transposePivotTable"+"<BR>");}


Till Next Time


Vismay said...

Hi John,

I have used your code for showing the horizontal pivot section, but the sections are not straight. There is a gap at the starting position of the sections.


Chris said...

This seems to work with the Chart Only Option. Do you know how I can use this if the chart is above a table?

John Minkjan said...


Can you eloborate a bit? Which space do you mean? You can use a program like firebug to identify it.

John Minkjan said...


Can you eloborate? It works fine for me with only table? Are you sure the javascript is without faults?

Anonymous said...

Can you please send code for displaying in two columns only?

nir said...

How can I hide the static view text from being displayed on screen below the pivot table view?

nir said...

How can I hide the static view text from being displayed on screen below the pivot table view?

John Minkjan said...


set var intColumnNumbers = 2;



John Minkjan said...


Set the CSS style to display:none

Milind said...

Hi John,

Is it possible to combine 2 pivot tables displayed in the same compound layout.Both the pivot tables have the same formatting and similar columns, but because of some client formatting requirement i need to create 2 pivots and now am trying to combine them.


John Minkjan said...


Much easier if you use a union all (combined by simliar request) and make only one pivt table

Friends said...

Hi john, i dont find any css stlye option for the static text - properties? please let me know where can i find it?

Thank you for your solution.

Thanks in advance

Stewart Hangewa said...

Hi John, do you probably have the code update for OBIEE 11g? It doesn't seem to work in 11g. Thanks!

Anonymous said...

Hi John,
Can you please post the code referred to the 11g, becouse the code does not work in 11g?

Anonymous said...

hi John,
I have a requirement to create a union with Col X, Col A in one report and Col X, Col B in 2nd report. Now the final results report should show Colx, Col A/B. Is this doable in OBIEE ? Many thanks for your help