Working with Crosstab Component In Pentaho Report Designer

This blog will teach reader about Working with Crosstab Component In Pentaho Report Designer

Crosstab is an experimental feature in Pentaho Report Designer . By default we can’t see crosstab component in PRD.

To enable this feature we need to do some modifications in Edit – > Preferences


In this Panel , go to “Other Settings” Tab and check the 2nd Option i.e, “Enable (unsupported) experimental features”.

Then Crosstab component will be automatically visible in PRD.

Data Source : JDBC : Sample Data Memory

Query :


If we will preview this query then we will get the data like below :


But In the above resultset it is very difficult to analyze the data .

So , its better visualization , I decided to create report with crosstab on this query .

Steps :

  1. Go to Master Report in Structure Tab
  2. On the right click of Master Report click on Add Crosstab Group


  1. Then you will find the below window


  1. Here you need to decide which field you want to see in row and which in column , accordingly set the fields you will get the output .



Now Preview the report you will find something like below :




Rupam Bhardwaj

Helical IT Solutions

Adding dollar($) sign to X-axis lables(values) for bar charts in pentaho CDE

Hi Guys,
Using below java script one can easily add ‘$’ sign to the values of X-axis for any charts in pentaho CDE.

function f(v) { return “$” + sprintf(‘%d’, v/1000) + ‘k’; }

Write the java code in “orthoAxisTickFormatter” java script wizard.

Make sure to give orthoAxisTicks as “True”
Sample output:

This code works with 13.06 as well with 13.09 version of pentaho CDE.

Also note that in java script if one line is not executing then the remaining lines will not execute. i.e., for instance you have 10 lines of code and 4th line is not executed then the remaining lines will not execute. Check with an alert function.

Sadakar Pochampalli
BI developer


Bar chart with Target lines in pentaho CDE – making bars as lines using java script in pentaho CDE

Hi guys,
This post teach you how to make bars as lines in pentaho CDE.
Source for this post is :
Scenario : Some end users wants visualization of grouped bars as lines where one of the bar is as bar and remaining bars as targeted lines on the same bar.
Properties have to give:

Plot2 : True

Find the remaining properties in below image: version of CDE is : 13.06 but will work in higher versions also.


In “Extension points” for the chart component you need to give 3 properties from the first link.

They are

extensionPoints: {
plot2Dot_shape: ‘bar’,
plot2Dot_shapeSize: function() {
var diam = ||

return this.finished(diam);
plot2Dot_shapeAngle: function() {
return this.chart.isOrientationHorizontal() ? 0 : -Math.PI/2;

NOTE: Find the image for how to give the above code as properties in Extension points of chart  component.

 Sample output of the chart on dashboard after giving the above properties.

BI developer
(“Learning never exhausts the mind”)



Sorting and limit the bars on bar charts in Pentaho CDE without ORDER BY and limit functions in SQL Query ( Descending order)

Hi Guys…!!!
This post tech you how you can make your bar chart dynamic..
You can limit the number of bars on bar charts with out using the “limit” function in your query as well you can also sort the bars in ascending or descending order with out using ORDER by clause  in SQL.

Some times you might have to deal with this type of functionality in your dashboard.
So here is a working example. Follow the steps…
Pentaho BI server 4.8 stable with C-Tools(CDA,CDE,CDF 13.06) installed.
Aim : 
1) Creating a dashboard with two horizontal bar charts.
2) How to use single query result set for two charts
3) Order by the bar on the dashboard with out writing ORDER BY clause in SQL.
4) limit the number of bars on charts with out writing “LIMIT” clause in SQL

Suppose your result set is like below

Query Eg :
SELECT ColumnA, columnB,ColumnC from table_Name  GROUP BY ColumnA

Result set Assumption:
ColumnA          ColumnB       ColumnC
pentaho               45                     75
jasper                  23                     34
pdi                       90                     22
and assume there are 30 rows in the result set …

You are using single query to plot the two charts on dashboard using ColumnA,ColumnB & ColumnA,ColumnC.

When you use ORDER BY clause in the query, you can only either order by columnB or ColumnC but you can not order by with ColumnB and ColumnC.

* In CDE, there is a functionality called “Indexs”. Indexs for columns in pentaho CDE starts from 0,1,2 and etc.
* So ColumnA index is 0, ColumnB index is 1 and vice versa.

* Prepare your environment for the dashboard and have a look at the “Data sources” now.
* Click on “Output Options” and give index values as 0,1,2 by clicking “add” button multiple times.

How to get ColumnA, ColumnB on first chart ? (B’z you are using single query result set)
* Now click on the first chart component
* In the Advanced properties click on “Pre Execution”
* Write the below code to fetch ColumnA, ColumnB on first bar chart.

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

ColumnA=category and  is accessed with Index 0
ColumnB=value and is accessed with Index 1
index2 is written in the code b’z to ignore the value appending to the category showed on bars.

How to sort and limit the bars on first chart ?(B’z you are using single query result set)

* Click on the “Post Fetch” option from the Advanced properties.
* Write this code, this code will limit the number of bars on chart and sort the bars in descending order.
* In the code below “param_no_of_end_points” is the parameter created in the “Generic” section.
* And for the parameter create a select in the “Selects” section with “Text input” component.

function f1(cdaData) {
var categIndex = 0;
var valueIndex = 1;

var param_no_of_end_points = +Dashboards.getParameterValue(“param_no_of_end_points”);

param_no_of_end_points = 0;

var resultset = cdaData.resultset.slice();
var compareDesc = function(a, b)
return a === b ? 0 : a > b ? 1 : -1;
function(rowa, rowb)
return compareDesc(+rowa[valueIndex],+rowb[valueIndex]);

if(param_no_of_end_points > 0)
cdaData.resultset = resultset;
cdaData = {
metadata: cdaData.metadata,
resultset:  resultset
return cdaData;

Write the same code for the second chart but make sure to use different function names and Index value. In an application we can not write two functions with same name.

Save the the dashboard and see the preview.

Meet us for more solutions @

BI developer


Date Input Controls/ Components in Pentaho CDE with a working example

Hello guys…!!!

In this post you will learn about how to create date input controls in CDE.
The dashboard images which I am going to show below are having lots of .css code. I’m not covering all the things but concentrating only on Date input controls in CDE.

My Environment :
BI Server: Pentaho 4.5
CTools: Not found the version numbers of  C-Tools(Unable to check them)– perhaps..! lesser than 13
Database : hsqldb (Comes along with Pentaho installation — A java based small db for servers like pentaho)
NOTE: Images are taken in this post after creating the dashboard, please find the yellow rectangular boxes to understand.

You need to work out @ 3 places in “Components” section.
1. Generic
2. Selects
3. Charts
Explained from step 1 to step 3
You need to work out  @ 1 places in “Data Sources” section. i.e, all in “Properties”
I’m not concentrating on Layout part for this example. So wherever the HtmlObject you find in this example replace them with your working HtmlObjects.

Step 1: Creating parameters
* Design your dashboard as per your requirement ( In the images you can find the sample designs).
 In the “Components” section:
1. Click on components
2. Click on Generic
3. Click on Date parameter
4. Go to properties give the name
eg: param_start_date
5. Click + symbol  per another date parameter
6. Go to properties give the name
eg: param_end_date

Find the  image

Step 2: Creating Date input Components
In the “Components” section
1. Click on Components
2. Click on Selects
3. Click on “Date input Component”
4. Go to Properties give name. eg: start_date in  my example
5. In the properties give HtmlObject. eg: start_date_select
* HtmlObject is the name of the column where you are putting
your dateinput control.
6. Give  Parameter.[It will appear once you try to type]
eg: In step 1, created parameters. So here give “param_start_date”
7. Give Listeners[click on it, you will find the list of Listeners. Click OK]
8. Repeat 3-7 for “end_date” Date input

Step 3:
Find the steps in image.

HtmlObject is the place where you are putting your chart.

Step 4: Applying parameters for Chart & Query
            In the “DataSources”
Find the steps in the image
Find the sub sequent image for  Parameters applying for chart & Query.

do same as shown in images.

Step 5:
Save the dashboard and then Click on “Preview” button.
See the images below for sample out put with date input controls.
Preview of the dashboard with out any input controls selection

Preview of the dashboard after selecting date input controls.. find the images below one by one.

Find the image for observing whether the chart becomes dynamic or not with different date input controls.

That’s it.. You are done with date input controls on dashboard.
Thank you for reading this small post.

[email protected]
Helical IT Solutions Pvt. Ltd,