6 Creating Business Queries

This chapter explains how to create queries in Oracle Business Activity Monitoring (Oracle BAM).

This chapter includes the following sections:

6.1 Understanding Business Queries

A business query or query is a request for data that matches specified conditions.

A query can fetch from a data object once, on a schedule, or continuously.

A Flat SQL Query is a simple table of data fields and their values. You select the data object and then select the data fields.

A Group SQL Query query is an analysis of one or more numeric data fields, called measures, grouped by non-numeric data fields called dimensions. For example, a group SQL query might analyze sales grouped by country. You select the data object and then select the measures and dimensions.

A Tree Model Query, written in SQL, is an analysis of one or more measures grouped by a hierarchy of dimensions. For example, a tree model query might analyze sales grouped by country, state or province, county or district, and city. You select the data object and then select the measures and a hierarchy.

A Continuous Query is an analysis of data collected in real time. For example, a continuous query might fetch the call volume for a call center every ten minutes. There are multiple continuous query templates, which perform these analyses:

  • Detecting trends

  • Detecting duplicates

  • Monitoring counts

  • Monitoring aggregate values such as averages

  • Detecting missing events

  • Monitoring highest aggregate values

  • Monitoring key performance indicators (KPIs)

You cannot use a continuous query in any view. However, you can add the Insert values into a data object alert action to a continuous query. You can then use the data object that receives the values, called a write-back data object, as the basis for another query and view. See Insert values into a data object for more information.

Continuous queries are written in Continuous Query Language, or CQL. Unlike SQL, which operates on data in a database or cache and responds to client requests, CQL operates on data in-memory and pushes the results to clients.

In any query that fetches measure data, a measure can be any calculated field defined in the data object. For more information about calculated fields in data objects, see Working with Data Objects.

Table 6-1 summarizes the data object types and business view types with which each business query type can be used.

Table 6-1 Query Type Compatibility with Data Object Types and View Types

This Business Query Type Fetches Data From Sends Data To

Flat SQL Query

Any non-stream data object

List, Action List, and Geo Map views only

Group SQL Query

Any non-stream data object

All views except List, Action List, Geo Map, Treemap, or KPI Watchlist

Tree Model Query

A non-stream data object with at least one hierarchy

Treemap views only

Continuous Query: Duplicate Detection Template

A stream data object only

Alerts only

Continuous Query: all other templates

Any non-external data object

Alerts only

A KPI Watchlist view is only for KPIs; see Creating KPIs for more information.

For more information about data objects, see Working with Data Objects.

For more information about views, see Creating and Using Business Views. For further details about the query requirements for each view type, see Table 8-1.

For more information about alerts, see Creating Alerts.

6.2 Business Query Prerequisites and Uses

Before you can create a query, you must add to your project the data object containing the data fields the query will retrieve and analyze.

For more information about projects, see Planning and Creating Projects. For more information about data objects, see Working with Data Objects.

After you create queries, you can use them in the following ways:

In a KPI

A realtime KPI can use a continuous query to monitor a risk indicator. A scheduled KPI must be based on a group SQL query with no dimensions. See Creating KPIs for more information.

In a view

A view displays the data that a non-continuous query retrieves. You cannot use a continuous query in any view. See Creating and Using Business Views for more information.

In a dashboard

A dashboard contains a group of related views. See Creating Dashboards for more information.

With a parameter

You can filter query data using a user-specified parameter value. See Creating Parameters for more information.

With an alert

A continuous query can initiate an alert action. For example, you can define an action that notifies you when the value of an Internal Costs field exceeds a certain dollar amount. This alert action is specific to the query and does not appear in the left panel navigator under Alerts. As an alternative, you can configure an alert to watch a continuous query as its triggering event. For more information, see Creating Alerts.

6.3 Creating a Flat SQL Query

This section outlines the procedure to create a Flat SQL Query.

To create a flat SQL query:

  1. Go to the Designer page.
  2. Click Business Queries in the left panel navigator, or right-click Business Queries and select the Create menu item.

    The Business Queries dialog opens.

  3. Type a Name and optionally edit the Display Name, select Flat SQL Query, and click Create.

    The Name is case sensitive, must begin with a letter, and may consist only of letters, numbers, and the underscore character. It may have up to 128 characters. It cannot be changed after the query is created.

    The Display Name is case sensitive and may contain any characters except the forward slash (/), which indicates a folder path. It may have up to 128 characters. It can be changed at any time.

    A tab opens for the new query.

  4. Select a Data Object.

    Data fields in the data object are listed.

  5. Check the boxes to the left of the data fields to include in the query. To include all fields in the data object, check Select All.

    To be used in a Geo Map view, a flat SQL query must include Address and Country Code fields or Latitude and Longitude fields, and one measure. See Creating Geo Map Business Views for more information.

  6. Optionally use the Move Up and Move Down icons to move the selected data field up or down in the list.

    The first-to-last order of the list determines the left-to-right order in which the fields are displayed in a view.

  7. Optionally click the Sort Order icon to toggle between ascending order, descending order, and unsorted for a data field. The default is unsorted.

    This determines the order in which data values are displayed in the column of the resulting table. If multiple fields are sorted, the fields listed first take precedence.

  8. To display only a specific number of the highest values for each numeric data field, check Top N at the bottom of the tab and type a number for N. The default is 3. See Using Top N Data for more information.
  9. Optionally add filters. See Filtering Data for more information.
  10. Optionally edit the Display Name. Mouse over the name in the top left corner of the tab and the name becomes editable.
  11. Click Save.

    Preview data appears at the bottom of the tab.

  12. If you configured an initial or default value for a parameter in a filter, the Input Values dialog appears. Optionally edit the value. Click OK to accept the parameter input value.
  13. Optionally display a preview, XML code, or SQL code for the saved query.
    • To display a preview of how the data might look in a table view, click the Preview icon.

      If you configured an initial or default value for a parameter in a filter, the Input Values dialog appears. Optionally edit the value. Click OK to accept the parameter input value.

    • To display the query in XML format, click the Modifier icon.

    • To display the query as an SQL statement, click the SQL icon.

    If the preview area is not displayed, click the Restore Pane icon in the lower right corner of the tab.

6.4 Creating a Group SQL Query

This section outlines the procedure to create a Group SQL Query.

To create a group SQL query:

  1. Go to the Designer page.
  2. Click Business Queries in the left panel navigator, or right-click Business Queries and select the Create menu item.

    The Business Queries dialog opens.

  3. Type a Name and optionally edit the Display Name, select Group SQL Query, and click Create.

    The Name is case sensitive, must begin with a letter, and may consist only of letters, numbers, and the underscore character. It may have up to 128 characters. It cannot be changed after the query is created.

    The Display Name is case sensitive and may contain any characters except the forward slash (/), which indicates a folder path. It may have up to 128 characters. It can be changed at any time.

    A tab opens for the new query.

  4. Select a Data Object.

    Data fields in the data object are listed.

  5. Check the boxes to the left of the Measures (Y-axis) data fields to include in the query.
  6. Optionally use the Move Up and Move Down icons to move the selected data field up or down in the Measures list.

    The first-to-last order of the list determines the left-to-right order in which the fields are displayed in a view.

  7. For each selected data field, display the drop-down list and check one or more aggregation functions. To specify all aggregation functions, check All. See Applying Aggregate Functions to Groups for more information.
  8. To display only a specific number of the highest values for each numeric data field, check Top N at the bottom of the tab and type a number for N. The default is 3. See Using Top N Data for more information.
  9. Check the boxes to the left of the Dimensions (X-axis) data fields to include in the query. These are the categories by which the Measure data field values are grouped for aggregation.

    If you are using the query in a Scheduled KPI or a Gauge type view, do not select any dimensions. For more information, see Creating a Scheduled KPI or Creating Gauge Business Views.

  10. If you check a datetime field as a dimension, the Time Grouping dialog appears. See Using a Time Group or a Time Series for information about how to define a time series or time group.

    Note:

    If a Group SQL query uses a datetime dimension with Quarter, Week, DayOfYear, or DayOfMonth as time units in graph views, drill to details and hierarchical drilling does not work.
  11. Optionally use the Move Up and Move Down icons to move the selected data field up or down in the Dimensions list.

    The first-to-last order of the list determines the left-to-right order in which the fields are displayed in a view.

  12. Optionally click the Sort Order icon to toggle between ascending order, descending order, and unsorted for a Dimension data field. The default is unsorted.

    This determines the order in which data values are displayed in views. If multiple fields are sorted, the fields listed first take precedence.

  13. Optionally select a Legend.

    If specified, this is the most important Dimension data field used for grouping. The legend matches values in this field to the colors used in a view. For example, a bar chart view with a Department legend might show green for Sales, blue for Development, and red for Production.

  14. Optionally add filters. See Filtering Data for more information.
  15. Optionally edit the Display Name. Mouse over the name in the top left corner of the tab and the name becomes editable.
  16. Click Save.

    Preview data appears at the bottom of the tab.

  17. If you configured an initial or default value for a parameter in a filter, the Input Values dialog appears. Optionally edit the value. Click OK to accept the parameter input value.
  18. Optionally display a preview, XML code, or SQL code for the saved query.
    • To display a preview of how the data might look in a table view, click the Preview icon.

    • To display a preview of how the data might look in a bar graph view, click the Bar Graph icon.

    • To display a preview of how the data might look in a line graph view, click the Line Graph icon.

    • To display a preview of how the data might look in a pivot table view, click the Pivot Table icon.

    • To display the query in XML format, click the Modifier icon.

    • To display the query as an SQL statement, click the SQL icon.

    If the preview area is not displayed, click the Restore Pane arrow icon in the lower right corner of the tab.

    If you configured an initial or default value for a parameter in a filter, the Input Values dialog appears when you select any of the preview icons. Optionally edit the value. Click OK to accept the parameter input value.

6.5 Creating a Tree Model Query

This section outlines the procedure to create a Tree Model Query.

A tree model query is applicable only to a data object with at least one hierarchy of dimension data fields defined. For example, a hierarchy might consist of the country, state or province, and city. See Working with Data Objects for more information.

You can use a tree model query only in a Treemap view, which is designed to display hierarchical data effectively. See Creating Treemap Business Views for more information.

To create a tree model query:

  1. Go to the Designer page.
  2. Click Business Queries in the left panel navigator, or right-click Business Queries and select the Create menu item.

    The Business Queries dialog opens.

  3. Type a Name and optionally edit the Display Name, select Tree Model Query, and click Create.

    The Name is case sensitive, must begin with a letter, and may consist only of letters, numbers, and the underscore character. It may have up to 128 characters. It cannot be changed after the query is created.

    The Display Name is case sensitive and may contain any characters except the forward slash (/), which indicates a folder path. It may have up to 128 characters. It can be changed at any time.

    A tab opens for the new query.

  4. Select a Data Object.

    Data fields in the data object are listed.

  5. Check the boxes to the left of the Measures (Y-axis) data fields to include in the query.
  6. Optionally use the Move Up and Move Down icons to move the selected data field up or down in the Measures list.
  7. For each selected data field, display the drop-down list and check one or more aggregation functions. To specify all aggregation functions, check All. See Applying Aggregate Functions to Groups for more information.
  8. To display only a specific number of the highest values for each numeric data field, check Top N at the bottom of the tab and type a number for N. The default is 3. See Using Top N Data for more information.
  9. Select a Hierarchy from the drop-down list. The data fields in the hierarchy are the categories by which the Measure data field values are grouped for aggregation. Datetime hierarchies are not supported.
  10. Optionally add filters. See Filtering Data for more information.
  11. Optionally edit the Display Name. Mouse over the name in the top left corner of the tab and the name becomes editable.
  12. Click Save.

    Preview data appears at the bottom of the tab.

  13. If you configured an initial or default value for a parameter in a filter, the Input Values dialog appears. Optionally edit the value. Click OK to accept the parameter input value.
  14. Optionally display a preview, XML code, or SQL code for the saved query.
    • To display a preview of how the data might look in a table view, click the Preview icon.

    • To display the query in XML format, click the Modifier icon.

    • To display the query as an SQL statement, click the SQL icon.

    If the preview area is not displayed, click the Restore Pane arrow icon in the lower right corner of the tab.

    If you configured an initial or default value for a parameter in a filter, the Input Values dialog appears when you select any of the preview icons. Optionally edit the value. Click OK to accept the parameter input value.

6.6 Creating a Continuous Query

This section outlines the procedure to create a Continuous Query.

Continuous queries use templates. Each template has its own settings. Therefore, the steps to create a continuous query are different for each template.

To create a continuous query:

  1. Go to the Designer page.
  2. Click Business Queries in the left panel navigator, or right-click Business Queries and select the Create menu item.

    The Business Queries dialog opens.

  3. Type a Name and optionally edit the Display Name, select Continuous Query, and click Create.

    The Name is case sensitive, must begin with a letter, and may consist only of letters, numbers, and the underscore character. It may have up to 128 characters. It cannot be changed after the query is created.

    The Display Name is case sensitive and may contain any characters except the forward slash (/), which indicates a folder path. It may have up to 128 characters. It can be changed at any time.

    A tab opens for the new query.

  4. Optionally check Activate Continuous Queries: Name to activate the query. The query is activated after it is saved if this box is checked.

    You can uncheck this box later to deactivate the query without deleting it.

  5. Select a Template. See one of the following sections for detailed steps on using the template you select.

    Note:

    All templates now support calculated fields when you select a Measure Field or use the Group By option. However, an embedded calculated field, that is — one calculated field within another, is not supported.

  6. Optionally edit the Description.

    A default description is provided based on the template you selected. You can edit the description to include the specific options you selected in the template.

  7. Click Save.
  8. Optionally display a preview of the CQL statement for the saved query. For continuous queries, the Preview icon is a magnifying glass in the upper right corner of the tab.
  9. The <add action> option appears after you save the query. You can optionally add an alert action that fires when the query detects out-of-range conditions. For more information about alert actions, see Alert Actions.

    As an alternative to creating an alert action in the query, you can configure an alert to watch a continuous query as its triggering event. See Select a CQL Query for more information.

  10. Click Save again if you configured an alert action.

6.6.1 Using the Trending Detection Template

This template detects when a numeric field shows a specified percentage change in value for a specified number of consecutive intervals. For example, such a query might detect when the call volume for a call center increases by 10% for two consecutive 30-minute intervals.

To create a continuous query using the Trending Detection Template:

  1. Specify the following Measure settings:
    • Data Object — The data object containing the measure the query will analyze.

    • Filter — Click the funnel icon to optionally add filters. This icon is clickable after you select a data object. See Filtering Data for more information.

    • Measure Field — The numeric field the query measures.

    • Aggregation Function — Select None, Maximum, Minimum, Count, Sum, or Average. See Applying Aggregate Functions to Groups for more information.

    • Group By — Select the dimensions by which the Measure Field values are grouped for aggregation. You can select All. This option is not displayed if the Aggregation Function is set to None.

      Time Grouping is not supported for continuous queries.

    • Partition By — Select the ordered fields by which the Measure Field values are partitioned. You can select All.

      Partitioning data values groups them without performing an aggregation function on them. Therefore, this option is displayed only if the Aggregation Function is set to None.

    • Use rolling window — Optionally check this box to define a period over which and a frequency at which the aggregation or partition is determined for incoming data. For example, you could update the number of calls completed in the last hour every ten minutes.

      For archived relation data objects, this setting is checked automatically and cannot be unchecked.

    • Range Length — The period over which the aggregation or partition is determined, from an amount of time in the past to the present. Examples of ranges are the last 15 or 30 minutes.

      If you specify more than one hour, a message appears warning of possible performance degradation when you select Save or Preview.

    • Update Interval — The aggregation or partition is determined every time new incoming data is received. The update interval determines how often the result within the rolling window is updated.

    • Units — Select Day, Hour, Minute, or Second for the Range Length and Update Interval.

    • Based on — A date or time column upon which the rolling window calculation is based. For example, choosing Call Start Time enables the system to determine whether a given call is within the rolling window period.

      This setting is displayed only if the selected data object is a relation. It is not supported for stream data objects.

  2. Specify the following Trending settings:
    • Change: Operation — Select greater than, greater than or equal to, less than, or less than or equal to.

    • Change: Percent — Type a value between 1 and 100 inclusive for the percent of change to the measure.

    • Consecutive Interval — Type an integer value representing the number of Update Interval occurrences needed to trigger an alert.

  3. Specify Output options to be included in the alert notification. The data field value options presented depend on the Measure Field. You can select All.

6.6.2 Using the Duplicate Detection Template

The Duplicate Detection Template can only query stream type data objects.

This template detects when a data field has duplicate values within a specified period of time. For example, such a query might detect when the same order is placed twice within a day.

To create a continuous query using the Duplicate Detection Template:

  1. Specify the following Measure settings:
    • Data Object — The data object containing the measure the query will analyze.

    • Measure Field — The field the query analyzes for duplicates.

    • Use rolling window — Use of a rolling window is mandatory for this template. This defines a period over which and a frequency at which the aggregation or partition is determined for incoming data. For example, you could update the number of calls completed in the last hour every ten minutes.

    • Range Length — The period over which data values are analyzed for duplicates, from an amount of time in the past to the present. Examples of ranges are the last 15 or 30 minutes.

      If you specify more than one hour, a message appears warning of possible performance degradation when you select Save or Preview.

    • Units — Select Day, Hour, Minute, or Second for the Range Length.

  2. Specify Output options to be included in the alert notification. The data field value options presented depend on the Measure Field. You can select All.

    Note:

    The Duplicate Detection Template does not support calculated fields. The Measure Field and Output options will not contain any calculated fields from the data object.

6.6.3 Using the Monitor Count Template

This template monitors the count of one or more data fields. For example, such a query might monitor the number of currently active calls in a call center.

To create a continuous query using the Monitor Count Template:

  1. Specify the following Measure settings:
    • Data Object — The data object containing the measure the query will analyze.

    • Filter — Click the funnel icon to optionally add filters. This icon is clickable after you select a data object. See Filtering Data for more information.

    • Measure Field — The field the query counts. You can select All to specify all fields in the data object that can be counted.

    • Group By — Select the dimensions by which the Measure Field values are grouped for counting. You can select All.

      If a Measure Field cannot be grouped by the selected Group By field, values in that Measure Field are concatenated in the Output.

    • Count: Operation — Select greater than, greater than or equal to, less than, less than or equal to, or equal to.

    • Count: Threshold — Type an integer value for the threshold to be compared to the count.

    • Use rolling window — Optionally check this box to define a period over which and a frequency at which the aggregation or partition is determined for incoming data. For example, you could update the number of calls completed in the last hour every ten minutes.

      For archived relation data objects, this setting is checked automatically and cannot be unchecked.

    • Range Length — The period over which the aggregation or partition is determined, from an amount of time in the past to the present. Examples of ranges are the last 15 or 30 minutes.

      If you specify more than one hour, a message appears warning of possible performance degradation when you select Save or Preview.

    • Update Interval — The count is determined every time new incoming data is received. The update interval determines how often the result within the rolling window is updated.

    • Units — Select Day, Hour, Minute, or Second for the Range Length and Update Interval.

    • Based on — A date or time column upon which the rolling window calculation is based. For example, choosing Call Start Time enables the system to determine whether a given call is within the rolling window period.

      This setting is displayed only if the selected data object is a relation. It is not supported for stream data objects.

  2. Specify Output options to be included in the alert notification. The data field value options presented depend on the Measure Field. You can select All.

6.6.4 Using the Moving Aggregation Template

This template monitors an aggregation (average, sum, and so on) of one or more data fields. For example, such a query might monitor the average wait time for calls in a call center.

To create a continuous query using the Moving Aggregation Template:

  1. Specify the following Measure settings:
    • Data Object — The data object containing the measure the query will analyze.

    • Filter — Click the funnel icon to optionally add filters. This icon is clickable after you select a data object. See Filtering Data for more information.

    • Measure Field — The numeric fields the query measures.

    • Aggregation Function — Select All, Maximum, Minimum, Count, Sum, or Average for each selected Measure Field. See Applying Aggregate Functions to Groups for more information.

    • Group By — Select the dimensions by which the Measure Field values are grouped for aggregation. You can select All.

      Time Grouping is not supported for continuous queries.

    • Use rolling window — Optionally check this box to define a period over which and a frequency at which the aggregation or partition is determined for incoming data. For example, you could update the number of calls completed in the last hour every ten minutes.

      For archived relation data objects, this setting is checked automatically and cannot be unchecked.

    • Range Length — The period over which the aggregation or partition is determined, from an amount of time in the past to the present. Examples of ranges are the last 15 or 30 minutes.

      If you specify more than one hour, a message appears warning of possible performance degradation when you select Save or Preview.

    • Update Interval — The aggregation is calculated every time new incoming data is received. The update interval determines how often the result within the rolling window is updated.

    • Units — Select Day, Hour, Minute, or Second for the Range Length and Update Interval.

    • Based on — A date or time column upon which the rolling window calculation is based. For example, choosing Call Start Time enables the system to determine whether a given call is within the rolling window period.

      This setting is displayed only if the selected data object is a relation. It is not supported for stream data objects.

  2. Specify Output options to be included in the alert notification. The data field value options presented depend on the Measure Field. You can select All.

6.6.5 Using the Missing Event Template

This template detects when an expected event does not occur. For example, such a query might detect when order approval is missing between order placement and order shipment.

To create a continuous query using the Missing Event Template:

  1. Specify the following Measure settings:
    • Data Object — The data object containing the measure the query will analyze.

    • Filter — Click the funnel icon to optionally add filters. This icon is clickable after you select a data object. See Filtering Data for more information.

    • Measure Field — The ordered fields the query measures. You can select All.

    • Partition By — Select the ordered fields by which the Measure Field values are partitioned. You can select All.

      Partitioning data values groups them without performing an aggregation function on them.

    • Use rolling window — Optionally check this box to define a period over which and a frequency at which the aggregation or partition is determined for incoming data. For example, you could update the number of calls completed in the last hour every ten minutes.

      For archived relation data objects, this setting is checked automatically and cannot be unchecked.

    • Range Length — The period over which the aggregation or partition is determined, from an amount of time in the past to the present. Examples of ranges are the last 15 or 30 minutes.

      If you specify more than one hour, a message appears warning of possible performance degradation when you select Save or Preview.

    • Update Interval — The partition is determined every time new incoming data is received. The update interval determines how often the result within the rolling window is updated.

    • Units — Select Day, Hour, Minute, or Second for the Range Length and Update Interval.

    • Based on — A date or time column upon which the rolling window calculation is based. For example, choosing Call Start Time enables the system to determine whether a given call is within the rolling window period.

      This setting is displayed only if the selected data object is a relation. It is not supported for stream data objects.

  2. Specify the following Event settings:
    • Pattern — Select one of the following patterns:

      • Event A is not followed directly by Event B — Event B does not occur immediately after Event A.

      • Event C is missing between Event A and Event B — Event C does not occur between Event A and Event B.

      • Event A is not followed by Event B in specific duration — Event B does not occur within a specified period of time after Event A.

    • Event A, Event B, and Event C — Select the following settings for each event.

      • Field — Select the data field that represents the event.

      • Operation — Select greater than, less than, or equal to.

      • Value — Type a value to which the event field is compared.

      Settings for Event C appear only if Event C is missing between Event A and Event B is selected.

    • Duration — Type an integer and select Day, Hour, Minute, or Second.

      This setting appears only if Event A is not followed by Event B in specific duration is selected.

  3. Specify Output options to be included in the alert notification. The data field value options presented depend on the Measure and Partition By fields. You can select All.

6.6.6 Using the Top N Template

This template monitors the top values of a grouped aggregation (average, sum, and so on) of a numeric field. For example, such a query might monitor which three countries have the top sales totals.

To create a continuous query using the Top N Template:

  1. Specify the following Measure settings:
    • Data Object — The data object containing the measure the query will analyze.

    • Filter — Click the funnel icon to optionally add filters. This icon is clickable after you select a data object. See Filtering Data for more information.

    • Measure Field — The numeric field the query measures.

    • Aggregation Function — Select Maximum, Minimum, Count, Sum, or Average. See Applying Aggregate Functions to Groups for more information.

    • Group By — Select the dimensions by which the Measure Field values are grouped for aggregation. You can select All.

      Time Grouping is not supported for continuous queries.

    • Top N — Specify the number of highest values to be fetched for the Measure Field aggregation groups. For example, you could specify the countries with the top three sales figures.

    • Use rolling window — Optionally check this box to define a period over which and a frequency at which the aggregation or partition is determined for incoming data. For example, you could update the number of calls completed in the last hour every ten minutes.

      For archived relation data objects, this setting is checked automatically and cannot be unchecked.

    • Range Length — The period over which the aggregation or partition is determined, from an amount of time in the past to the present. Examples of ranges are the last 15 or 30 minutes.

      If you specify more than one hour, a message appears warning of possible performance degradation when you select Save or Preview.

    • Update Interval — The aggregation is calculated every time new incoming data is received. The update interval determines how often the result within the rolling window is updated.

    • Units — Select Day, Hour, Minute, or Second for the Range Length and Update Interval.

    • Based on — A date or time column upon which the rolling window calculation is based. For example, choosing Call Start Time enables the system to determine whether a given call is within the rolling window period.

      This setting is displayed only if the selected data object is a relation. It is not supported for stream data objects.

  2. Specify Output options to be included in the alert notification. The data field value options presented depend on the Measure Field. You can select All.

6.6.7 Using the KPI Alert Template

A continuous query that uses the KPI Alert Template is similar to a realtime KPI. However, you can use a realtime KPI in a KPI watchlist view. You cannot use a continuous query in any view. See Creating KPIs for more information about KPIs.

This template detects when a grouped aggregation (average, sum, and so on) of a numeric field shows a specified change from a defined norm. For example, such a query might detect when the call volume for a call center is more than one standard deviation from the average of the last 24 hours.

To create a continuous query using the KPI Alert Template:

  1. Specify the following Measure settings:
    • Data Object — The data object containing the measure the query will analyze.

    • Filter — Click the funnel icon to optionally add filters. This icon is clickable after you select a data object. See Filtering Data for more information.

    • Measure Field — The numeric field the query measures.

    • Aggregation Function — Select Moving Average, Moving Sum, Moving Min, or Moving Max. See Applying Aggregate Functions to Groups for more information.

    • Group By — Select the dimensions by which the Measure Field values are grouped for aggregation. You can select All.

      Time Grouping is not supported for continuous queries.

    • Use rolling window — Optionally check this box to define a period over which and a frequency at which the aggregation or partition is determined for incoming data. For example, you could update the number of calls completed in the last hour every ten minutes.

      For archived relation data objects, this setting is checked automatically and cannot be unchecked.

    • Range Length — The period over which the aggregation or partition is determined, from an amount of time in the past to the present. Examples of ranges are the last 15 or 30 minutes.

      If you specify more than one hour, a message appears warning of possible performance degradation when you select Save or Preview.

    • Update Interval — The aggregation is recalculated every time new incoming data is received. The update interval determines how often the result within the rolling window is updated.

    • Units — Select Day, Hour, Minute, or Second for the Range Length and Update Interval.

    • Based on — A date or time column upon which the rolling window calculation is based. For example, choosing Call Start Time enables the system to determine whether a given call is within the rolling window period.

      This setting is displayed only if the selected data object is a relation. It is not supported for stream data objects.

  2. Specify the following Threshold settings:
    • Criteria — Specify one of the following threshold criteria:

      • Measure is greater than a (Norm + Deviation) — Measure values are higher than a threshold.

      • Measure is less than a (Norm – Deviation) — Measure values are lower than a threshold.

      • Measure is not within a (Norm +/– Deviation) — Measure values are either higher or lower than thresholds that define a normal range.

    • Norm Definition: Constant — Type an integer value in the Simple Value text box to define the norm.

    • Norm Definition: Historical — Specify the following settings to define a historical norm:

      • Aggregation Function — Select Average, Sum, Min, or Max.

      • Window Size — The period over which the aggregation is calculated, from an amount of time in the past to the present. Examples of window sizes are the last 30 minutes or the last 24 hours.

      • Based on — A date or time column upon which the rolling window calculation is based. For example, choosing Call Start Time enables the system to determine whether a given call is within the rolling window period.

        This setting is displayed only if the selected data object is a relation. It is not supported for stream data objects.

      • Refresh Time — The first or next time the historical norm will be calculated.

      • Refresh Frequency — The frequency at which the norm is recalculated.

      • Units — Select Month, Week, Day, Hour, Minute, or Second for the Window Size and Refresh Frequency.

    • Deviation Definition — Specify the following settings to define a deviation from the norm:

      • Scalar Value — Type an integer value to define the deviation.

      • Percent of Norm — Type a percentage of the norm.

      • Calculation — Type a multiplier in the Times text box and select Standard Deviation or Variance.

  3. Specify the following Alert Event: Output options to be included in the alert notification:
    • All — The measure, norm, allowed deviation, and actual deviation values.

    • Measure — The measure value.

      Norm — The norm value.

      Allowed Deviation — The lower or upper threshold value, or both.

      Actual Deviation — The difference between the measure value and the norm.

6.7 Creating a Pre-defined SQL Query

Oracle BAM allows you to write your own SQL which can then be used for flat or group queries against that SQL. The arbitrary SQL that you enter is treated as a sub-query by the system. The returned result set is treated as set of columns like in a Data Object.

To create a pre-defined SQL:
  1. Go to the Designer page.
  2. Click Business Queries in the left panel navigator, or right-click Business Queries and select the Create menu item.
    The Business Queries dialog opens.
  3. Type a Name and optionally edit the Display Name, select Flat/Group SQL Query, and click Create.

    The Name is case sensitive, must begin with a letter, and may consist only of letters, numbers, and the underscore character. It may have up to 128 characters. It cannot be changed after the query is created.

    The Display Name is case sensitive and may contain any characters except the forward slash (/), which indicates a folder path. It may have up to 128 characters. It can be changed at any time. A tab opens for the new query.
  4. Click the ‘Yes’ button next to the ‘Create query based on defined SQL’.
    A Data Source drop-down list appears.
  5. Choose a data source from the drop-down list. The data source you choose must have all data server information – including a username and password - already pre-configured on the Weblogic Server Administration Console.
  6. Enter the SQL statement you need. You can modify the pre-defined SQL statement as needed. Columns are generated according to your SQL statement and when the SQL changes, they’re updated accordingly.

    Note: Hierarchical queries are not supported within pre-defined SQL queries.

    Note: Pre-defined SQL queries do not support duplicate column names. If your query has two or more identical column names, they must be renamed to ensure that the resulting SQL query columns are unique.

  7. To view editable fields, measures, dimensions, and filters, click outside the SQL statement box, or save or preview the SQL statement.
  8. If you have based your SQL on a flat query:
    1. Select the fields and filters you need for you want to apply. To include all fields in the data object, check Select All.
    2. To be used in a Geo Map view, a flat SQL query must include Address and Country Code fields or Latitude and Longitude fields, and one measure. See Section 7.3.5, "Creating Geo Map Business Views" for more information.
    3. Optionally use the Move Up and Move Down icons to move the selected data field up or down in the list. The first-to-last order of the list determines the left-to-right order in which the fields are displayed in a view.
    4. Optionally click the Sort Order icon to toggle between ascending order, descending order, and unsorted for a data field. The default is unsorted. This determines the order in which data values are displayed in the column of the resulting table. If multiple fields are sorted, the fields listed first take precedence.
  9. If you have created your SQL based on a group query:
    1. Check the boxes to the left of the Measures (Y-axis) data fields to include in the query. These are the categories by which the Measure data field values are grouped for aggregation.
    2. Optionally use the Move Up and Move Down icons to move the selected data field up or down in the Measures list. The first-to-last order of the list determines the left-to-right order in which the fields are displayed in a view.
    3. For each selected measure, display the drop-down list and check one or more aggregation functions. To specify all aggregation functions, check All. See Section 5.13, "Applying Aggregate Functions to Groups" for more information.
      Note that aggregations (SQL GROUP BY) are applied on top of the pre-defined SQL query which may already have aggregations performed. You can select the SUM aggregation to effectively pass through values from opaque query that already does aggregation.
    4. Check the boxes to the left of the Dimensions (X-axis) data fields to include in the query. These are the categories by which the Measure data field values are grouped for aggregation.
    5. If you are using the query in a Scheduled KPI or a Gauge type view, do not select any dimensions. For more information, see Section 6.4, "Creating a Scheduled KPI" or Section 7.3.4, "Creating Gauge Business Views."
    6. If you check a datetime field as a dimension, the Time Grouping dialog appears. See Section 5.14, "Using a Time Group or a Time Series" for information about how to define a time series or time group.
    7. Optionally use the Move Up and Move Down icons to move the selected data field up or down in the Dimensions list. The first-to-last order of the list determines the left-to-right order in which the fields are displayed in a view.
    8. The first-to-last order of the list determines the left-to-right order in which the fields are displayed in a view. This determines the order in which data values are displayed in views. If multiple fields are sorted, the fields listed first take precedence.
  10. Optionally add filters. See Section 5.11, "Filtering Data" for more information.
  11. Click Save.
    Preview data appears at the bottom of the tab.
  12. At the bottom of the page, you can see a ‘Top N’’ checkbox. If you want to get the highest values for each field, you can enable this check box.
  13. Select a number for N. The default value is 0.
  14. Optionally select a Legend. If specified, this is the most important Dimension data field used for grouping. The legend matches values in this field to the colors used in a view. For example, a bar chart view with a Department legend might show green for Sales, blue for Development, and red for Production.
  15. Optionally edit the Display Name. Mouse over the name in the top left corner of the tab and the name becomes editable.
  16. Click Save.
    Preview data appears at the bottom of the tab.
  17. Optionally display a preview, bar graph, line graph, pivot table, XML code, or SQL code for the saved query.
    1. To display a preview of how the data might look in a table view, click the Preview icon.
    2. To display a preview of how the data might look in a bar graph view, click the Bar Graph icon.
    3. To display a preview of how the data might look in a line graph view, click the Line Graph icon.
    4. To display a preview of how the data might look in a pivot table view, click the Pivot Table icon.
    5. To display the query in XML format, click the Modifier icon.
    6. To display the query as an SQL statement, click the SQL icon.
    If the preview area is not displayed, click the Restore Pane arrow icon in the lower right corner of the tab.
  18. If you configured an initial or default value for a parameter in a filter, the Input Values dialog appears when you select any of the preview icons. Optionally edit the value. Click OK to accept the parameter input value.

6.8 Editing a Business Query

When you edit a query, the changes propagate to all views that include the query and all dashboards that include these views.

Use the following procedure to open, edit, and save a query.

To edit a query:

  1. In the left navigation pane, click the arrow to the left of Business Queries.

    All saved queries in the current project are displayed in a list.

  2. Click the query name, or right-click the query name and select the Edit menu item.
  3. Make the desired changes.
  4. Click Save.

    Note:

    Before editing a query, close any business views, editors, or dashboards that are using it. This ensures that there is no data transmission loss to any dependent artifacts of the business query in use.

6.9 Renaming a Business Query

This section outlines the procedure to rename a Business Query.

Use the following procedure to change the Display Name of a query.

The Display Name is case sensitive and may contain any characters except the forward slash (/), which indicates a folder path. It may have up to 128 characters. It can be changed at any time.

To rename a query:

  1. In the left navigation pane, click the arrow to the left of Business Queries.

    All saved queries in the current project are displayed in a list.

  2. To rename the query, right-click the query name and select the Rename menu item.

    The name becomes text in an editable field.

  3. Type the new name and press Enter.

    The new name appears in the list.

When you edit the query, the new Display Name is displayed on the tab. However, the internal Name remains unchanged. When you edit the query, this name is displayed on the left in the header.

6.10 Deleting a Business Query

This section outlines the procedure to delete a Business Query. The query is removed from any views or dashboards that reference it.

Use the following procedure to delete a query.

To delete a query:

  1. In the left navigation pane, click the arrow to the left of Business Queries.

    All saved queries in the current project are displayed in a list.

  2. Click the query icon and click the Delete icon, or right-click the query name and select the Delete menu item.

    A dialog asks you to confirm the query deletion.

  3. Click OK.

    The query disappears from the list.

6.11 Securing a Business Query

A query inherits security settings from the project in which it is created.

For more information about projects, see Planning and Creating Projects.

To change security settings for a query:

  1. In the left navigation pane, click the arrow to the left of Business Queries.

    All saved queries in the current project are displayed in a list.

  2. Right-click the query and select Security Settings from the pop-up menu.

    The security tab for the query opens.

  3. To add a role or group to whom you can explicitly grant or deny permissions, follow these steps:

    1. Click the Add icon in the Grant Permissions or Deny Permissions table.

      The Add Application Roles, Groups, and Users dialog opens.

      See Managing Oracle BAM Users for information about how to add users to roles and groups.

    2. Type a Name for the role or group you are adding.

    3. Select from the drop-down List: Application Role or Group.

    4. Click Search to populate the Available Members list.

    5. To add a member to the Selected Members list, select the member and click the single right arrow.

    6. To add all members to the Selected Members list, select the member and click the double right arrow.

    7. To remove members from the Selected Members list, use the single and double left arrows.

    8. When the Selected Members list is final, click OK.

      The Add Application Roles, Groups, and Users dialog closes, and the Name you specified appears in the table.

  4. To remove a role or group, select the table row and click the Remove icon.

  5. To grant permissions, select Read, Write, Remove, or Security for the users, roles, and groups listed in the Grant Permissions table.

  6. To deny permissions, select Read, Write, Remove, or Security for the users, roles, and groups listed in the Deny Permissions table.

  7. Click Save.

6.12 Filtering Data

You can add data filters to most types of queries. You can also filter data in some alert operations.

A simple example filter is "Sales greater than 12000." When this filter is applied, only rows with values larger than 12000 in the Sales data field are fetched. See When a data field in a data object meets specified conditions and Delete rows from a data object for more information.

By adding logical sub-branches, you can create a hierarchy of filters. (In previous releases, branches were called headers.)

To filter data completely, fetching no rows from the data object, check Filter All Data.

To add a row data filter:

  1. Click the New Filter icon.

    The Add/Edit Filter dialog appears.

  2. Select the data field to be filtered from the drop-down list on the left.
  3. Select the operation from the drop-down list in the center. The default operation is is equal to. See Filter Comparison Operations for more information.
  4. Select the item with which to compare the value in the filtered data field:
    • Type a Value — A value you specify.

      Note:

      The auto-suggest feature doesn't work for calculated fields in filters. If you type a valid value and refresh, you can still see the results.
    • Select a Column — The value in another data field.

    • Select a Parameter — User input through a parameter. See Creating Parameters for more information.

    • Select a Token — A token. Select User Application Roles to specify the security roles with access to the query. Select Current User to specify the name of the currently logged-in user. See Securing a Business Query for information about granting access to the query.

  5. Click OK to save the filter.
  6. Optionally edit the root branch, which is All are true by default. Select the branch and click the Edit icon. Then choose one of the following branch types and click OK:
    • All are true — A row is fetched if all filters under the branch are true.

    • Any is true — A row is fetched if at least one filter under the branch is true.

    • Not all are true — A row is fetched if at least one filter under the branch is false.

    • None is true — A row is fetched if all filters under the branch are false.

  7. Optionally select the root branch and click the New Branch icon to add a sub-branch. Then choose one of the branch types listed in the previous step and click OK.
  8. Optionally add any additional filters or sub-branches you need. A branch does nothing unless at least one filter is under it. To delete a branch or filter, select it and click the Delete icon.
  9. Click Save.

6.12.1 Adding a Group Data Filter

You can add group data filters to business queries, for example, sum of sales or average of sales, or count of region. You can apply the group filters to queries at run-time as well.

To add a group filter:
  1. Select the Group Filters tab.
  2. Click the New Filter icon. The Add/Edit Filter dialog appears.
  3. Select the data field to be filtered from the drop-down list on the left.
  4. Select the operation from the drop-down list in the center. The default operation is is equal to.
  5. Select the item with which to compare the value in the filtered data field.
  6. Type a Value — A value you specify. Alternatively, select a Parameter — User input through a parameter. See Creating Parameters for more information.
  7. Click OK to save the filter.

6.12.2 Filter Comparison Operations

You can use the following operations for filter comparisons:

is equal to returns the exact value. For numeric data types, nulls are not fetched for filters using a typed-in value of zero. See Exceptions for Datetime Filter Comparisons for timestamp exceptions.

For numeric data types, nulls are not fetched for filters using an is equal to or is not equal to operation and a typed-in value of zero.

is less than returns values less than specified value.

is less than or equal to returns values less than or equal to specified value.

is greater than returns values greater than specified value.

is greater than or equal to returns values greater than or equal to specified value.

is not equal to returns all values except specified value. For numeric data types, nulls are not fetched for filters using a typed-in value of zero.

is like returns values that match a string pattern. Include an underscore (_) as a wildcard for a single character in a string, and a percent symbol (%) as a wildcard for one character or more. Wildcard characters can be combined, for example, %mm _00 would return all columns (35mm 200, 35mm 400, 35mm 800). Do not enter any spaces in the expression because spaces are treated as characters in the data match.

is not like returns values that do not match a string pattern. You can use the wildcard characters permitted in is like comparison expression.

is null returns values where the column is null.

is not null returns values where the column is not null.

is in list returns values included in a list. See Exceptions for Datetime Filter Comparisons for timestamp exceptions. When you select this option, the text box in which you can type a value expands to allow multiple values. Add as many values as needed, each on a separate line.

is not in list returns values not included in the list.

6.12.3 Exceptions for Datetime Filter Comparisons

You can use datetime data types with the is like or is not like operation, but you must specify the full datetime format, including the time zone. For example:

02/%/2014 08:%:% %M

The datetime value entered is assumed to be in the UTC time zone.

Note that is equal to and is in list filters do not work for timestamp values because Oracle databases use microsecond precision, while Oracle BAM uses second precision.

You can work around this limitation by creating two filters: one using is greater than or equal to and the desired value, and another using less than and the value plus one second.

For example, to create a filter for is equal to 10:05:30 11:14:35 AM:

  1. Make sure the type of the branch under which both filters are created is All are true.

  2. In the first filter, choose the operation is greater than or equal to and type the value 10:05:30 11:14:35.

  3. In the second filter, choose the operation is less than and type the value 10:05:30 11:14:36.

See Column Data Types for more information about the BAM datetime format.

6.13 Using Top N Data

You can choose to display only the top values of the first data field in Flat SQL Queries. In Group SQL and Tree Model Queries, you can select the data field to which to apply Top N.

In List and Action List views, you must apply sorting to a field before applying top N. The top N selection applies to the first sorted field.

If two or more values are the same, and not all of them can be included in the top N, which values are included is random. For example, if N is 3 and the top four are 100, 200, 300, and 300, one of the 300 values is omitted.

See Creating and Using Business Views for more information about views.

6.14 Applying Aggregate Functions to Groups

Many query types support adding aggregate functions to groups of data.

The aggregate functions are defined in Table 6-2.

Note:

When you use an aggregation function such as an average in a query, the first data point the query fetches will be null, because the aggregation of no data is null.

The Sum function is only supported for the integer data type. For decimal or float data types, exact values are not guaranteed.

Table 6-2 Aggregate Functions

Function Description

Count

For a field of any type, this function returns a count of the values, including duplicates.

Count Distinct

For a field of any type, this function returns a count of the unique values, not including duplicates.

Minimum

For a field of any type, this function returns the earliest, lowest, or alphanumeric first value in the group.

Maximum

For a field of any type, this function returns the latest, highest, or alphanumeric last value in the group.

Sum

For a numeric field, this function returns the sum.

Average

For a numeric field, this function returns the statistical average.

Median

For a numeric field, this function returns the statistical median. For a datetime field, it returns the middle chronological value. For a string field, it returns the middle alphanumeric value.

Std Dev

For a numeric field, this function returns the statistical standard deviation.

Variance

For a numeric field grouped by a dimension, this function returns the statistical variance accounted for by a particular group.

Percent of Total

For a numeric field grouped by a dimension, this function returns the group sum percentage of the sum of all groups. This function is not appropriate for fields that may sum to zero.

6.15 Using a Time Group or a Time Series

You can create a query and a corresponding view in which the grouping (X-axis) is based on a datetime field.

To configure a time group or series:

  1. Select a datetime field as a Dimension in a Group SQL Query or as a Group By field in a Continuous Query.

    To change a time group or series you have already configured, select the datetime field and click the Edit icon at the top of the Dimensions list.

    The Time Grouping dialog appears.

  2. Select either Use Time Series or Use Time Groups.
    • Use Time Series — Displays the data from the first datetime data point available in the data object to the last in the configured time interval.

    • Use Time Groups — Displays data grouped into a set number of time intervals. For example, if you select Month from the time unit list, all data from January from all years where data is available are grouped in one data point on the chart.

    Note:

    When using time-based queries, drilling hierarchy is only supported for queries with one dimension and single time units.
  3. Select Continuous Time Series to display empty groups for time intervals with no data. This setting appears only if you select Use Time Series.

    There may be time gaps in which the data object does not have entries. The Continuous Time Series feature adds groups to the result with values of zero, so that the X-axis appears as a smooth time series on a graph. The zero-value result may not appear at design time but shows up in your business view at run time.

    Continuous Time Series is valid only if you have chosen a single datetime field to group by. Continuous Time Series is not supported if any additional group fields are selected.

  4. Select a Time Unit from the list.

    If you selected Use Time Series, you can select one time unit. If you selected Use Time Groups, you can select more than one.

    • Year displays groups for all of the years where data is available. You can specify a Quantity of 1, 2, 5, or 10 years to include in each group.

    • Quarter displays four groups representing the quarters of a year (January-March, April-June, July-September, and October-December). You can specify a Quantity of 1 quarter.

      Note:

      If you use a Group SQL Query with the Continuous Time Series option, the Quarter time unit does not work when applied to graph views.
    • Month displays twelve groups representing the months of the year. You can specify a Quantity of 1, 2, 3, 4, 6, or 12 months.

    • Week displays 52 groups representing the weeks in a year. You can specify a Quantity of 1, 2, 4, 13, 26, or 52 weeks.

    • Day displays 365 groups representing the days in a year when it is the only time unit selected. Any additional time unit larger than Day in a time group determines the number of groups. For example, if you select Week and Day, seven groups representing the days of the week are displayed. You can specify a Quantity of 1 day.

    • Hour displays 24 groups representing the hours of a day. You can specify a Quantity of 1, 2, 3, 4, 6, 8, 12, or 24 hours.

    • Minute displays 60 groups representing the minutes in an hour. You can specify a Quantity of 1, 2, 3, 4, 5, 6, 10, 12, 15, 20, 30, or 60 minutes.

    • Second displays 60 groups representing the seconds in a minute. You can specify a Quantity of 1, 2, 3, 4, 5, 6, 10, 12, 15, 20, 30, or 60 seconds.

  5. Enter a Quantity of the time unit to group by. For example, entering a 2 next to the Month time unit displays the groups in two month increments (January and February are grouped as one data point on the chart).
  6. Click OK.

Figure 6-1 shows a bar chart view with time groups for years and quarters.

Figure 6-1 Bar Chart with Year and Quarter Time Groups

Description of Figure 6-1 follows
Description of "Figure 6-1 Bar Chart with Year and Quarter Time Groups"

Note:

Chart and Graph business views display non-continuous time series differently, in that graph business views space time unit data points along the x-axis evenly.