Creating SQL queries by using the visual query builder
The visual query builder supports the following BMC Helix ITSM views and field types:
Views
- Archived incidents
- Asset management
- Business workflows
- Change management
- Configuration management
- Incident management
- Problem management
- Service level management
- Service request management
- Task management
- Work order management
Field types
Dimension: These fields are text or data fields that are used to describe data.
Metric: These fields are used to measure numeric values, such as count and average.
Calculated: These fields are used as filters with predefined values.
Enum: These fields contain a set of constant values to choose from.
The following process flow explains the steps involved in creating queries by using the visual query builder.
Before you begin
Make sure that BMC Helix Dashboards is connected to BMC Helix ITSM.
To create queries by using the visual query builder
- On the Home page, click Add Visualization.
- From the Data source list, make sure that BMC Helix is selected.
- From the Query type list, select Service Management.
- From the Type list, select Visual query builder.
- On the Visual query builder page, perform these steps:
- From the View list, select the required view.
After you select the view, the left pane shows the fields that you can use to build the query. The fields are listed under view folders. - Select a view folder and drag the required fields to the Fields area.
- (Optional) To add the distinct statement to the query, select Use distinct.
- Click Preview.
The query is built and the results of the query are displayed in the table view. - (Optional) Add filters to view the subset of data fetched by the query.
For details, see To add filters to restrict data. - (Optional) Aggregate data fetched by the query.
For details, see To aggregate data. - (Optional) To make changes to the query, select and remove fields as required and preview the changes.
Note: You can remove fields by dropping them to the left pane in the list of fields. - (Optional) To change the sequence of fields, drag the fields to move them to the required position.
- Click SQL to view and verify the generated query.
- Click Use query.
You are directed to the panel configuration options and the query is copied in the query box.
- From the View list, select the required view.
- (Optional) To make changes to the query, perform any of these steps:
- Click Query Builder and make changes.
- From the Type list, select SQL and manually edit the query.
- (Optional) To remove all the existing view and field selections, click Reset.
- Apply visualizations and data transformations. For details, see Configuring-dashboards-panels-and-queries.
- Save the dashboard.
To add filters to restrict data
You can add filters to limit the amount of data that is returned by a query. Data is filtered based on the filter conditions that you specify. You can define conditions by using the operators; for example, define the following condition to view data only for the HR group: Group contains or equals HR
The following operators are supported to define filter conditions:
Operator | Description | Type |
---|---|---|
Greater than | Greater than a single alphanumeric or string value. | Numeric |
Less than | Less than a single alphanumeric or string value. | Numeric |
Equal | Equal to a single alphanumeric or string value. | Alphanumeric |
Greater or equal | Greater than or equal to a single alphanumeric or string value. | Numeric |
Less or equal | Less than or equal to a single alphanumeric or string value. | Numeric |
Exact match | Matches exactly with a single alphanumeric or string value. | Alphanumeric |
Contains | Record contains the filter text. | Text |
Does not contain | Record does not contain the filter text. | Text |
Begins with | String starts with a letter or letters. | Text |
Ends with | String ends with a letter or letters. | Text |
Is null | Record contains no value for selected attribute. No parameter can be set. | NA |
Is not null | Record contains any value. No parameter can be set. | NA |
In | One or more alphanumeric or string values. | Alphanumeric |
To apply filters
- Open the visual query builder.
- From the View list, select a view.
- Drag the required fields to the Fields area.
- Drag the fields to be used as filters to the Filters area.
Note: You can drag fields from Fields to Filters. The enum-type fields display a set of constant values. You can select a value instead of typing it manually. (Optional) Drag the calculated fields to be used as filters to the Filters area.
For more information about calculated fields, see the Using calculated fields as filters video.- Define filter conditions for the fields by using the operators.
- Preview and use the query.
Example
Bob is a dashboard user. He wants to view the problem summary and other details, such as impact, priority, urgency and assigned groups. He selects the Problem Management view and selects the specified fields under Problem Details. He previews the query and decides to apply the filter to view only critical queries. He applies the following filter:
Bob can now analyze the critical problems.
Query without the filter
Query with the filter applied
To aggregate data for analysis
You can aggregate data returned by a query. Use data aggregation to summarize data for useful analysis. The following aggregation functions are supported:
Aggregation function | Description | Data type |
---|---|---|
Average | Average of values returned by the query. | Numeric |
Count | Count of items returned by the query. | String and numeric |
Sum | Sum of all values returned by the query. | Numeric |
Maximum | Maximum value out of total values returned by the query. | Numeric |
Minimum | Minimum value out of total values returned by the query. | Numeric |
Count Distinct | Count of distinct items returned by the query. | String and numeric |
To aggregate data
- Open the visual query builder.
- From the View list, select a view.
- Drag the required fields to the Fields area.
- Click the required field and select an aggregate function.
- Preview and use the query.
Example
Carl is a Service Desk manager. He wants to view the incidents according to assigned groups. He selects the Incident Management view and drags the Incident Number and Assigned Group fields under Incident Details to the Fields area. He previews the query. The query results show the incident ID according to assigned groups. However, he wants to view the count of incidents for each assigned group. He uses the following Count aggregate function and previews the query:
Query without the count aggregation function
Query with the count aggregation function applied