This paper will illustrate how to build Dashboard (reports, charts) from Excel Spreadsheet. The data file is also provided so you can follow the steps.

For practice, you can download this excel spreadsheet and use the same SQL code in this document.
All of the SQL code that is highlighted in Yellow can be selected and copied using the Acrobat select option
Did you download InfoCaptor Dashboard Designer? If not, then it is a good idea to have it installed so you can follow the steps easily.

Launch InfoCaptor

Connect to the Excel file

If the path of the Excel file is “c:\files\data.xls” then use “\\” , result c:\\files\\data.xls
In this case the file to be used is “d:\\test_data.xls”.
Select “Excel File – sun.jdbc.odbc.JdbcOdbcDriver” from the Driver list.
Create your first Dashboard

- Click on the “New Dashboard” button (yellow highlight)
- Enter the desired dashboard name (green highlight)
- Click OK (blue highlight) – It creates an empty dashboard as shown below

Add content to your new Dashboard
Syntax for Querying Excel Worksheets
- Each worksheet in Excel file is treated like a SQL table
- The worksheet is referenced as [worksheet name$]
- You can perform normal SQL selects on this table
Your first Portlet (Qlet )
Lets create the first portlet
We will show the complete file in the portlet using below query
“Select * from [detail_data$]
{detail data is one of the worksheet in the test_data.xls file}

- Click on the “New Qlet” button or select Create à Query Portlet from Menu bar
- In the property window as shown above, enter the Qlet Name
- Select the Connection
- Enter you query in the text editor
- Click on the Apply button

Portlet Customizations
Once your portlet is visible, you can change the cosmetic features such as colors and fonts, increase/decrease column widths, change the location of the portlet and resize the portlet.
Create Summary Portlets
Using the same data, we can create any slice of data by grouping the numbers by any column. Click on the new Qlet button and type the following query
By Region
|
select country_region, sum(quantity_sold) as qty_sold, sum(amount_sold) as amt_sold from [detail_data$] group by country_region order by 3 desc |

“order by 3 desc” tells to sort by the third column in descending order. You can also mention the sort this way “order by sum(amount_sold) desc” or “order by sum(amount_sold) asc” for ascending
We will add few more portlets as shown below.
By Product Category
|
select prod_category, sum(quantity_sold) as qty_sold, sum(amount_sold) as amt_sold from [detail_data$] group by prod_category order by sum(amount_sold) desc |

By Channel
|
select channel_class, sum(quantity_sold) as qty_sold, sum(amount_sold) as amt_sold from [detail_data$] group by channel_class order by sum(amount_sold) desc |

By Now the dashboard should be getting crowded.

But what is a dashboard without charts? Lets add some colors to it with charts.
Create Pie Chart (Glet)
We will convert each of the above queries into Pie chart. For a pie chart we just need two columns, the first column becomes the base on which the pie sections are named after and the second column is the numeric column that decides the pie size for each section.
Since we have three columns in all of the above queries, we will pick the first and the second column.
- Click on the New Chart button
- Enter the name of the Glet
- Select the Chart Type (2d Pie or 3d Pie)
- Enter the following query
|
select country_region, sum(quantity_sold) as qty_sold from [detail_data$] group by country_region order by 3 desc |

We don’t need the order by clause for a pie chart. You can select “pie” , “Pie 3d” or “Ring” from the drop down.
|
Here is the 3D pie version |
Here is the “Ring” version |
 |
 |
Similarly lets create other pie charts
|
By Product Category Pie chart select prod_category, sum(quantity_sold) as qty_sold from [detail_data$] group by prod_category |
By Channel Class select channel_class, sum(quantity_sold) as qty_sold from [detail_data$] group by channel_class |
 |
 |
Your dashboard should look something like this

As you see the portlets are randomly placed and sized. We will take care of the placement and sizing later. Lets add few more stuff to the dashboard.
Now we add a Bar chart
Top Countries
|
select country_name, sum(quantity_sold) as qty_sold from [detail_data$] group by country_name order by sum(quantity_sold) desc |

We select the “Chart Type = Bar”, enter the query and hit “Full Apply”
The bar chart is displayed but there are few ugly things. The labels on the X-Axis are overlapping, we need proper names for the X and Y axes and what if we just need to see the “Top 5 Countries”?

As you see, we changed the Max Rows=5 which limits the bar chart to top 5 countries. We changed the X Axis label = Country, Y Axis label = Quantity Sold and finally we set the x Axis label angle to 30 degrees
Lets add another bar chart by Month
By Period
|
select calendar_month_name, sum(quantity_sold) as qty_sold from [detail_data$] group by calendar_month_name |

Now we align and re-size the portlets
Click on Menu à Edit à Show Grid. Drag the borders of each portlet and resize them as you see fit

Now that our dashboard is almost ready, we will add some parameters and make it more user friendly.
Year Parameter
Click on the new parameter button or from the menu select Create à Parameter

- Enter “Year” as the parameter name
- In the “Display Column” type “distinct fiscal_year”
- In the text editor type the worksheet name “FROM [detail_data$]”
- Click on “Fully Apply”
- The above is the result list of values
- The list of value is showing a decimal value, this is because of the Excel formatting.
- Change the query to add a condition as below. We will use the TRIM function (if you list of values shows a null value then also add a where condition to remove null value e.g “where fiscal_year <> ‘null’ “)

Similarly lets add the region parameter
Region Parameter

For this parameter we have enabled the “All Values”. We also added ‘country_region’ in the (ID1) Internal Column1 property. This is needed in order for ‘All Values’ to work.
Now we need to wire all the portlets to the above two parameters.
Link the Parameters to Portlet
Right now the parameters and the portlets are independent. In order to link the tables and charts to the parameter we need to modify the SQL queries for each portlet (table and chart). Select the ‘By Region’ and Edit it.
- The current query is
select country_region, sum(quantity_sold) as qty_sold, sum(amount_sold) as amt_sold from [detail_data$] group by country_region order by 3 desc |
- Just after [detail_data$], hit ‘Enter or return key’ to create a new line below
- Type and fiscal_year = , then right click just after the ‘=’ sign
- A list of all ‘Parameters’ is made visible.

- Select the ‘Year (p33) parameter, a sub-menu will popup
- Select ‘p33: Get Display >/*distinct TRIM(fiscal_year)*/
- p33 is the internal Identifier for the ‘Year’ parameter
- Once you select ‘p33: Get Display >/*distinct TRIM(fiscal_year)*/’, the query should be as shown below
select country_region, sum(quantity_sold) as qty_sold, sum(amount_sold) as amt_sold from [detail_data$] where fiscal_year = 'G_PARAM<p33:Display>' /*distincttrim(fiscal_year)*/ group by country_region order by 3 desc |
- Since “Year” is a numeric value, we will remove the quotes around G_PARAM<p33:Display> and remove the string /*distinct TRIM(fiscal_year)*/. So the final query looks as shown below
select country_region, sum(quantity_sold) as qty_sold, sum(amount_sold) as amt_sold from [detail_data$] where fiscal_year = G_PARAM<p33:Display> group by country_region order by 3 desc |
- The code G_PARAM<p33:Display> is an instruction to pick the current value of the “Year” parameter identified by id = p33 and get the Display Value
- When you click on ‘Full Apply’, the SQL query is dynamically reconstructed at run time to use the parameter value. If you go to menu Run à Display Log, click on ‘Log Enabled’ button, refresh the chart and go back to the Display Log, you will see the modified query as it is submitted.

- Similarly we add the condition for the ‘Region’ parameter

- For the “Region” we include a LIKE operator. Since we have enabled ‘All Values’ in the region parameter, the ‘All Values’ internally passes a ‘%’ character in the ‘ID1’ field, i.e if you select ‘All Values’ in the region parameter then the ‘G_PARAM<p34:ID1>’ will contain a value of ‘%’, in all other cases it will contain the actual country region.
- Here is the log display with ‘All Values’

- We will apply the above conditions to all the portlets. The resultant queries are as below
By Region
select country_region, sum(quantity_sold) as qty_sold, sum(amount_sold) as amt_sold from [detail_data$] where fiscal_year = G_PARAM<p33:Display> and country_region like 'G_PARAM<p34:ID1>' group by country_region order by 3 desc |
By Channel
select channel_class, sum(quantity_sold) as qty_sold from [detail_data$] where fiscal_year = G_PARAM<p33:Display> and country_region like 'G_PARAM<p34:ID1>' group by channel_class |
By Product Category
select prod_category, sum(quantity_sold) as qty_sold, sum(amount_sold) as amt_sold from [detail_data$] where fiscal_year = G_PARAM<p33:Display> and country_region like 'G_PARAM<p34:ID1>' group by prod_category order by sum(amount_sold) desc |
Top Countries
select country_name, sum(quantity_sold) as qty_sold from [detail_data$] where fiscal_year = G_PARAM<p33:Display> and country_region like 'G_PARAM<p34:ID1>' group by country_name order by sum(quantity_sold) desc |
By Period
select calendar_month_name, sum(quantity_sold) as qty_sold from [detail_data$] where fiscal_year = G_PARAM<p33:Display> and country_region like 'G_PARAM<p34:ID1>' group by calendar_month_name |
- When you change any of the parameters, you need to click on the ‘Refresh Dashboard’
button. This action refreshes the full dashboard.

Having to click on the ‘Refresh button’ everytime you change the parameter is little tedious. So is there a way where the dashboard refreshes automatically whenever there is a change in parameter?
Absolutely! Infact, you can control which portlet gets refreshed for any particular parameter change.
Dynamic Refresh of Dashboard when changing Parameter
First take a note of the internal identifiers for each of the Graph portlet and Query portlets.
When you click on any portlet, the internal ID is displayed at the bottom in the status bar

The internal ID for ‘By Region’ portlet is = ‘q32’.
Now we will add a trigger in the ‘Year’ parameter to refresh ‘By Region’ whenever the user changes or selects a year value

As shown above, edit the ‘Year’ parameter (right click on ‘Year’ title, select ‘Edit’)
Set “Run Dynamic Java Script” = ‘Y’
Click on the ‘Dynamic Java Script Editor’
Type the following command “//<REFRESH_LIST>q32</REFRESH_LIST>
You can refresh more than one portlet by adding the portlet id separated by comma
e.g. “//<REFRESH_LIST>q32,q34,g35</REFRESH_LIST>
Now if you need to refresh all the portlets then there is an easy shortcut
Just type “//<REFRESH_LIST>ALL</REFRESH_LIST> NOTE: “ALL” is in Caps
Similarly, add the trigger command to the ‘Region’ parameter

The Dashboard So Far

We will create a drill from the “By Region” portlet to a detail level by ‘By Region and Country’. So this detail level will tell us How is the Sales distributed among different countries for each ‘Region’
We need to create a new Qlet with the following SQL query
select country_region, country_name,sum(quantity_sold) as qty_sold, sum(amount_sold) as amt_sold from [detail_data$] where fiscal_year = G_PARAM<p33:Display> and country_region = 'param<Region Name,Asia>' group by country_region,country_name order by 3 desc |
In the above code, we introduced a new element which is called as Portlet Filters. Each portlet filter is defined using the following syntax [‘param<Filter name, default filter value>’]. The quotes at the beginning and end of the filter definition are needed if the column (in this case pldesc) is character. If the filter is against a numeric column then you don’t need the quotes.

Once you click ‘Apply’, it prompts you to enter the Filter value

- We can type any value in the ‘Region Name’ or just accept the default ‘Asia’ value.
- Click on ‘Apply’. The portlet is refreshed and the results are as shown below.

- Now focus on the ‘By Region’ Qlet
- Right click on the first column i.e. on any cell in the ‘Country Region’ column
- Switch to the Drill Settings Tab as shown in image above right.
- Click on the ‘Add’ button. Enter ‘Drill Name’, Select ‘Drill Into’ as ‘By Region and Country’

- Once you select the ‘Drill Into’ value as ‘By Region and Country’, the Parameter region will show the available parameters.
- Click on the values region and a drop down will appear. This is the list of available columns from the ‘By Region’ Qlet which is the parent Qlet.
- Select the ‘Country_region’ value
- Click on ‘Done and Close’
- Click on ‘Close’ on the Drill Settings tab
- Refresh the ‘By Regions’ Qlet and you will see the ‘Drill’ indicator on the ‘Country Region’ column

- Right click on any cell on the PL column

- Select ‘Get Details by Country’
- The child Qlet is refreshed and the drill value is displayed

- This completes the Drill definition and testing.
Column Names
- The first row of the Excel file is assumed to be the Column names.
- Its good idea to not have spaces in your column names. For e.g If possible convert a column name like Account Balance to “Account_Balance”. This way you can directly refer the column name in your SQL query. Alternatively, If you have blank spaces in between words in your Column name then put them in double quotes “Account Balance” , For e.g. Select sum(“Account Balance”) from [sheet1$]
Connection problems?
If your excel file “C:\\test_data.xls” is open in Excel, you cannot connect using InfoCaptor. Similarly if your Excel file is connected through InfoCaptor then you may not open it in Excel, you may lose your connection.