Every dashboard can have parameters, these parameters are values that can be set from forms then used in the SQL queries to allow forming customized queries. For example if you had a query selecting employees from a table, you could create a form allowing an employer to be selected, then in the charts sql you can use that parameter to return only the employees from that employer. Let's look at an example.

To create and use a form we:

  1. Add a new Form
  2. Add an input Component to the Form
  3. Use the Parameter in an SQL query

Add a new Form

The menu option for adding a form

Add an input Component to the Form

Adding an input component to a form.

Forms are used to group input components. Once you have added a form the form editor appears, we use the editor to add and configure components.

  1. First click on the Add ComboBox Component shown by the arrow.
  2. The key field is the name of our parameter, we will use this later our custom sql query.
  3. Options is a comma separated list of values that the user may choose from. (The list of options can also be created from an sql query, we'll cover this later)
  4. Label tells the end user what this input represents.

Here's an example input component that has been configured to give a list of countries as options

Adding an input component to a form.

Use the Parameter in an SQL query

Finally we use the key field from our component within an SQL chart query, using a dollar symbol to mark it as a parameter, sqlDashboards then replaces that parameter with your selected value before sending the query to the SQL server. In this example we have selected Italy as the country and are displaying its GDP and population. Using the parameter to customize our sql query.

Dollar Symbols in SQL Queries

Note that $ symbol is special and must be escaped.. Since the $ symbol is used to represent a sqlDashboards form parameter, we must escape it to make it pass through to SQL raw. To do that we use double dollar symbols. e.g.

Select * from tradeTable where curreny='$$'
would send only one dollar symbol to the SQL server.