Creating SQL queries by using Visual Query Builder
Supported BMC Helix ITSM views and field types
Visual Query Builder supports the following out-of-the-box BMC Helix ITSM views and field types:
Views
- Asset Management
- BWF Case Management
- BWF Knowledge Management
- Change Management
- Configuration Management
- Digital Workplace
- Incident Management
- Problem Management
ITSM Knowledge 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.
To enable or disable the display of out-of-the-box views in Visual Query Builder
If you want to create SQL queries based on custom views only, you can disable the display of out-of-the-box views in Visual Query Builder. By default, these views are displayed.
- Log in to the BMC Helix Dashboards as a reporting editor or administrator.
- From the navigation menu, select Administration > General > Default preferences.
- In the Manage dashboard features section, use the Enable OOTB views for Visual Query Builder option to enable or disable the display of views.
The changes are saved.
The following video (2 minutes) explains how to use Visual Query Builder to create SQL queries.
The following process flow explains the steps involved in creating queries by using Visual Query Builder.
Before you begin
Make sure that BMC Helix Dashboards is connected to BMC Helix ITSM.
To create SQL queries by using 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. When you hover over a field name, the corresponding database column name for the field is displayed. - 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) Apply functions to customize field values.
For details, see To apply functions to fields. - (Optional) To make changes to the query, select and remove fields as required and preview the changes.
You can remove fields by dragging 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 one of the following 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 Creating-and-customizing-dashboards and Creating-dashboards-with-advanced-functions.
- Save the dashboard.
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 | Record displays the values greater than the specified numeric value. | Numeric and enum |
Less than | Record displays the values less than the specified numeric value. | Numeric and enum |
Equal | Record displays the values equal to the specified alphanumeric or string value. | Alphanumeric |
Greater or equal | Record displays the values greater than or equal to the specified alphanumeric or string value. | Numeric and enum |
Less or equal | Record displays the values less than or equal to a single alphanumeric or string value. | Numeric and enum |
Exact match | Record displays the values that exactly match 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 | Sting starts with a letter or letters. | Text |
Between | Record contains a numeric value to specify a range; for example, date. | Numeric |
Ends with | Record ends with a letter or letters. | Text |
Is null | Record contains no value for the selected attribute. No parameter can be set. | NA |
Is not null | Record contains any value. No parameter can be set. | NA |
In | Record displays the values that match one or more alphanumeric or string values. | Alphanumeric and string |
Not equal | Record displays values that do not match one or more alphanumeric or string values. | Alphanumeric and string |
Not In | Record does not display the values that match one or more alphanumeric or string values. | Alphanumeric and string |
The default operator is equal for all fields except the Date field for which the default operator is between. The operators are displayed according to the field type; for example, if you select a string-type field, you will not see numeric operators, such as between and greater than.
You can also use dashboard variables as filters. For details, see this example. For information about creating and configuring dashboard variables, see Setting-up-variables-for-dashboard-queries.
To apply filters
- Open 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.
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) From the Calculated Fields folder, drag the calculated fields to be used as filters to the Filters area.
- Define filter conditions for the fields by using the operators.
- Preview and use the query.
Example: Apply filters while creating a query by using the Problem Management view
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
Example: Use a dashboard variable as a filter
Bob is a dashboard user who wants to view a list of incidents by submitters. He selects the Incident Management view and the required fields under Incident Details. He previews the query that shows the expected result. Bob now wants to view the incidents submitted by specific submitters. He adds the already-created Submitter dashboard variable to the Filters section and previews the query. The preview results show the incidents submitted by the submitters that match the condition defined in the dashboard filter.
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 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
Functions that can be applied to fields
Apply functions to fields to customize field values; for example, you can apply the String function to a string field to display all the string values in uppercase letters. The following functions are available:
- String: Use to customize the values of a string field by using any of the following options:
- Upper - Displays the string in uppercase.
- Lower - Displays the string in lowercase.
- Ltrim - Removes all the leading spaces from the string.
- Rtrim - Removes all the trailing spaces from the string.
- Length - Displays the number of characters in the string.
- String To Number - Displays the numeric value for the string.
- Date: Use to customize the values of a date field by using any of the following options:
- Date - Displays the date and time stamp.
- Weekday - Displays the number of the day in a week when the incident occurred.
- Day - Displays the number of days for which the incident is open.
- Week - Displays the number of the week when the incident occurred.
- Month - Displays the number of the month when the incident occurred.
- Quarter - Displays the number of the quarter when the incident occurred.
- Year - Displays the year when the incident occurred.
- First Day Of Month - Displays the first day of the month when the incident occurred.
- First Day Of Quarter - Displays the first day of the quarter when the incident occurred.
- First Day Of Year - Displays the first day of the year when the incident occurred.
- Weekday Name - Displays the day of the week when the incident occurred.
- Month Name - Displays the name of the month when the incident occurred.
- Time: Use to customize the time format for date fields by using any of the following options:
- Time - Displays the date and time stamp.
- Hour - Displays the time in hours.
- Minute - Displays the time in minutes.
- Second - Displays the time in seconds.
To apply the String, Date, or Time function to a field
- Open Visual Query Builder.
- From the View list, select a view.
- Drag the required fields to the Fields area.
- (Optional) Drag the fields to be used as filters to the Filters area.
Click the required field and select the appropriate String, Date, or Time function.
The functions are displayed according to the type of field.- To remove the applied function, select None.
- Preview and use the query.