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

Friday 23 August 2013

Reading data from single data source(Single SQL Query) for two charts in pentaho CDE

Hi guys...!!!

Community Dashboard Editor is the best reporting/dash boarding  tool that I have worked. It's smart functionality made me love to work with it and exploring the things time by time.

You'll learn how to fetch different columns from result set of a single query and use them in different analysis purpose in charting.

Recently I needed to work with a single query data source(SQL) of having 3 columns result set ...
Lets say there are 3 columns A,B and C where as A column is having some category names and B and C are having some columns.

A  B   C
--------------
abc 2   4
pqr  6   8 
xyz 10 5
and etc.

From the result set A&B are on first chart and A&C are on other chart..
Now how ?????? This question leads me to check the "Data sources" section of CDE.

Follow the steps below.

1) Click on the "sqloverjndi" which  you created for your SQL query.
2)  In the properties section you can find an option called "Output options". Just click on  it.
3) Let's say you have 3 columns in your result set and these 3 columns takes index values starting from 0 to n.. i.e., A column index is 0 , B column index is 1 and for the C  value 2 is the index.

  NOTE: if you have more numbers of columns you can give as many indexes by clicking "Add" button as many times.
4)For Chart 1:
  i) Click on the chart component where you want show A& B columns ( A is category B is value)
  ii) In the properties(Click on Advanced properties) click on "Pre Execution"
  iii) Write this below code
            function f() {
                                 this.chartDefinition.readers = [
                                 {names:'category', indexes: 0},
                                  {names: 'value', indexes: 1},
                                    {indexs: 2}
                                    ];
             } 

  Why this {indexs:2} ? if you omit this the values of index2 append to the category names... to eliminate that problem you need to write it.

 5) For Chart2 :
 Repeat the steps in in point 4)
 Slight changes in code ...

function f() {
                                 this.chartDefinition.readers = [
                                 {names:'category', indexes: 0},
                                  {names: 'value', indexes: 1},
                                    {indexs: 2}
                                    ];
             } 


You are done with reading data from single query of 3 columns where 1&2 for one chart and 1&3 for another chart...

Save your dashboard and see the preview.

Sadakar
BI developer 
( "Learning never exhausts the mind" )

No comments:

Post a Comment