Pentaho Tools :

Pentaho C-Tools(CDE,CDF,CDA),Pentaho CE & EE Server,OLAP-Cubes,Analysis using Pivot4J, Saiku Analytics, Saiku Reporting, Ad-hoc Reporting using Interactive Reporting Tool,Dashboards,Reports using PRD, PDD,Data Integration using Kettle ETL,Data Mining usign WEKA,Integration of Servers with Databases,Mobile/iPad compatible Dashboards using Bootstrap Css,Drilldown dashboards,Interactive Dashboards

Wednesday, 2 July 2014

Columns Grand total in Table component of Pentaho CDE

Hi Guys,

Table component has no direct feature of adding column totals as of this post written date(July 2nd 2013)....

Here is the pentaho community & data tables shared java script  to find the Summation of columns in Table component.

Write below code in Draw Function of Table Component.

function f() {
    var grandTotalRow = "<tfoot><tr><td>Total</td>";
 
  for(i=1;i<4;i++) {
        var total=0;
         var rows = $('#' + this.htmlObject + ' tbody tr');
         
          rows.each(function() {
            var cellVal = parseFloat($('td:eq('+i+')', this).text().replace(',',''));
           
          if(!isNaN(cellVal)){
              total+=cellVal;
          }
           
           });
        grandTotalRow += "<td>"+total.toFixed(2);+"</td>";
        }
          grandTotalRow += "</tr></tfoot>";
          if($('#'+this.htmlObject+' tfoot').length===0)
        $('#'+this.htmlObject).find('table').append(grandTotalRow);

    }



Sample output:

References :

https://www.datatables.net/forums/discussion/17132/summary-footer-row

http://forums.pentaho.com/showthread.php?94187-Table-Component-Grand-total

Example :
https://metrics.mozilla.com/data/content/pentaho-cdf-dd/Render?solution=metrics2&path=%2FgetInvolved&file=getInvolved.wcdf