Report Definition Query tab

The Query tab defines the content of the report, including the rows and columns included in the report. The information on this tab determines the SQL query that runs to retrieve the data for the report.

Complete the Edit columns section to define the columns to include, and how to format and display their values. Complete the Edit filters section to describe which class instances or records to include.

Edit columns

This section defines the columns in the report. Columns display in the report in the same order as in this list. To change the column display order, drag and drop the column in the list.

For each column in the report, the following fields are available:

Field Description
Column source Specify a Single Value property, which may be a top-level or embedded scalar property, identified by a property reference.

Instead of specifying an existing Single Value property, you can use the Calculation Builder to select a function template and provide database columns for it to operate on. The column in the report displays the result of the SQL function. To open the Calculation Builder, click the Calculation Builder icon. For more information, see The Calculation Builder.

If your application has declare index rules, you can choose one of the properties in the declare index as a column. Type part of the declare index name and click the down-arrow. The rule appears as one of the Best Bets.

When using a Report Definition to query the search index, you may need to modify the list of filterable and returnable properties for that class. See How class instances are stored in the search index and Specifying custom search properties.

If you enter the name of property that has not been optimized, your system might experience a performance slowdown when running the report. You might want to use unoptimized properties while working out the report's structure and contents, but optimize all properties before moving the code to a production system.

Note: Reports that use unoptimized properties in filters or selects result in a warning message in the Report Editor or the report definition. Reports that have a join filter with unexposed properties result in a run-time error.

In many situations, you can use a linked property to populate a column (or the right side of a filter condition; see below). If you are building a report on unresolved work items, you can include a column with the access group of the creator of the work item by using the linked property .pxCreateOperator.pyAccessGroup.

You cannot reference data page properties that take parameters (such as D_page1[companyName:D_page2[param2:Param.P1],param2:pxRequestor.pyUserIdentifier].pyLabel).

Column name Enter a column heading to be used for this column on the report. By default, the label defined for the selected property appears as the column heading.

This field is required for most columns, but is not required when the Summary function field has a value.

Summarize Specify one of the built-in functions COUNT(), COUNT DISTINCT(), SUM(), AVG(), MAX(), or MIN() to aggregate the data in the column. Depending on your choice of property for the column, some summary functions might not appear as options.

If a summarize function is selected, two filter conditions sections will be displayed: Filter conditions to apply BEFORE aggregation and Filter conditions to apply BEFORE aggregation.

If summarize function is not selected, only one filter conditions section will be displayed.

Sort type Optional. For each sorted column, you specify one of the following options:
  • Ascending (default): Values for the column are sorted in ascending order, from lowest to highest.
  • Descending: Values for the column are sorted in descending order, from highest to lowest.
Sort order Optional. If you are sorting the values for more than one column on the report, enter a unique value for each sorted column as an integer between 1 and the number of sorted columns.

Click the Options icon to select formatting options for that column in the Edit column options window:

Option Description
Column width Specify the column width as a percentage of the window's width or in pixels. Enter an integer in the first field, and select either px or % in the second field.
Column format Specify a format to use for the values for the column. Leave blank to use the default format associated with the property. Many formats accept parameters.
Display values across columns Available only for summary reports. Check to create a pivot-table style report, in which values for one or more columns display horizontally.
Hide column Available only for list reports. Check to hide the column in the displayed report.

Edit filters

This section defines filter conditions, which determine which rows of data are included in the report. If you leave this section empty, the report selects all instances of the Applies to class (or instances or records of whatever sources are indicated on the Data Access tab), up to the limit in the Maximum number of rows to retrieve field on the Data Access tab. Pega Platform converts information in this section to an SQL WHERE clause when retrieving data from the database.

Note: To prevent reports that run a long time and impact performance, define appropriate filter conditions. Define filter conditions that are as restrictive as possible, while still including the data needed for the report user.

Filter conditions

If any column in the report includes a Summarize function, an additional section title Filter conditions to apply BEFORE aggregation is displayed, and a separate section is displayed for filters after aggregation. If no columns have a Summarize function, these additional items are not displayed.

If you define filter conditions in this section, you must enter a logical expression in the Filter conditions text box above the list of filter conditions. Using the labels entered in the Condition column, enter a logical expression that specifies how to combine the conditions. The expression can include parentheses and the operators AND and OR. For example, if the table contains four rows labeled A, B, C, and D, you can enter an expression like (A OR B OR C) AND D. The expression must include all labels within the Condition column; that is, it must include every filter condition.

Each row of the array in this section identifies a filter condition. The order of rows is not significant. Pega Platform converts information in this array to an SQL WHERE clause when retrieving data from the database.

Field Description
Condition Specify a letter (or letters) that uniquely identifies this row. This condition is used to reference this row in the Logic field, and can be as simple as A for the first row, B for the second row, and so on. Conditions can have letters and numbers, but no spaces, and you cannot use the words "And" or "Or", as they are used to relate the various filters.
Caption Optional: Provide a caption to identify the filter condition in the Filters list that displays above the data when the report runs.

Depending on which option you selected for Filter caption settings at the bottom of the section, the caption you set for each condition applies to the column within the condition (if the caption is "customer", then "customer = 'brown'"), or to the entire condition ("customer").

Column source Specify a property reference for the conditions. The property referenced must be exposed as a database column in the Applies To class for the report value, or else be a fully qualified value to a clipboard page that is always present on the clipboard, such as the requestor page or process page.
CAUTION:
You can specify only Single Value properties that are either top-level or scalar embedded properties in the Column field. Each property you identify for selection criteria must be exposed as a column in the database table.

You can specify Single Value properties that are produced by an SQL function. To use the result of an SQL function query, click the Calculation Builder icon to the right of the field. The Calculation Builder opens, and you can select an SQL function and specify parameters. For more information, see The Calculation Builder.

Note: If the type of this property is TextEncrypted, special instructions apply to the Condition and Value fields.

If you enter .pxObjClass and the Applies To class of this report definition is a framework class, and if the developer has checked the Report on descendant class instances check box in the Report Definition form, at run time the report can use the corresponding implementation class, not the framework class, for comparisons and report content. This feature eliminates the need to copy each framework class-based report definition into the implementation class.

When you specify an embedded property in a page list or page group, you must enter an index or name for each page list or age group; for example, pyproductList(1).pyProdName. However, this index is ignored at run time, which results in an ANY-type filter being generated that is satisfied if any value in the page list or page group satisfies the condition.

Relationship Select a logical operator for the comparison condition, such as Is equal or Starts with.
Note: If you select Contains and specify a function as the column value, the filter operator is modified to "=" instead of "LIKE". Use an SQL function in the Column source field instead of the Value field to generate the Contains logic in an SQL statement.
Value Specify one of the following options as a comparison value:
  • A literal constant, formatted in accordance with the property type. To compare the Column value with multiple literal constants, surround each with quotation marks and separate each with a comma. Place a backslash character \ before any quotation mark that appears within the constant. In some situations, you can click the Select values button to review current clipboard values for the property identified in the Column field.
  • A fully qualified property reference to a Single Value property that is present on the clipboard at run time. The Type of this property must match the type of the property in the Column field.
  • A fully qualified property reference to a Value List or Value Group property present on the clipboard at run time. The Type of this property must match the type of the property in the Column field. To compare the Column value with multiple Value List or Value Group properties, separate each property name with a comma.
  • A reference to a parameter that is defined in the report's rule, in the format param.name.
  • The name of another Single Value property that is exposed as a column. This allows comparison of the values of two properties in the same instance (database row), if the types are identical or comparable.
  • A calculation. To compare with the result of a calculation, click the Calculation Builder icon to the right of the field. The Calculation Builder opens, and you can select an SQL function and specify parameters. For more information, see The Calculation Builder.
  • A symbolic date, for a Date or DateTime value. When the list value rule executes, this symbolic reference is converted to an actual date or date range based on the time zone of the user and the Condition value. For example, if the user selects Last Year and the Condition value is IS EQUAL TO, the result is a date range between January 1 and December 31 inclusive, of the previous calendar year.
  • A literal value. The StartDate is the filter value. If the StartDate and the EndDate values specify the number of seconds, the system adds 999 milliseconds to the initial value. Otherwise, the system adds 59 seconds and 999 milliseconds to the initial value. For example, if the EndDate value is 20200212T132100.165 GMT, the system adds 999 milliseconds, and the value in the report is 20200212T132200.164 GMT.
    Based on one of the following conditions to select, the system chooses the StartDate or the EndDate values as the filter values:
    Is equal
    Values between the StartDateand the EndDate range.
    Is not equal
    Values not between the StartDate and the EndDate range.
    Is less than / Greater than or equal
    The StartDate becomes the filter value.
    Is greater than / Less than or equal
    The EndDate becomes the filter value.

If the Relationship field is set to IS NULL or IS NOT NULL, leave this field blank.

Commas correspond to an OR test: If the Value field contains two or more entries separated by commas, the comparison is true at run time if the value of the Column field equals (or is greater than, or is contained in, and so on) any one of the entries.

When the Value field contains a Value List or Value Group property reference, the comparison is true at run time if the value of the Column field is true for any element in the list or group.

When evaluating either of the two Condition values Greater or Greater or Equal at run time, the result is the same as applying the test to the largest value in a list or group. Similarly, when evaluating the Condition values Less or Less or Equal at run time, the result is the same as applying the test to the smallest value in the group or list. The Value List and Value Group options are most useful for other condition values, such as Contains or Starts with.

Using the Select values window

The Select values window provides one or more of the following tabs:

  • Available values — The system searches the column in the database corresponding to the property in the Column field to collect and display up to 1,000 values for the Column property in a new window. To add literal values to the Value field, check one or more boxes and click OK. (You can also type literal constants directly, whether or not they appear on this list.) This tab appears at run time only to users who hold the standard privilege @baseclass.ShowStoredValues. For such users, it is visible at run time when the Display available values? box in the Prompt settings area is selected.
  • Valid values — The system presents values determined by the Table type specification on the General tab of the property referenced in the Column field. To add literal values to the Value field, check one or more boxes and click Apply. This tab appears at run time when the Display valid values? box in the Prompt settings area is selected.
  • Compatible columns — The system lists exposed properties with the same Type as the property in the Column field, as candidates for this field. This tab appears at run time when the Display compatible columns? box in the Prompt settings area is selected.
  • Time Periods — For a property of type Date or DateTime, allows the selection of a symbolic date such as Yesterday or Current Year.
  • Calendar — Allows selection of a date by using a calendar interface.

Click the Options icon at the right of any condition row to edit the filter options:

Option Description
Field value key Provide the field value key used for localizing the Select Values pop-up window that opens from the Report Viewer when a user changes filter conditions.
Report Viewer options Select a value to determine how a user of this report can modify the condition in this row when the report is run and displayed in the Report Viewer.
  • Allow any changes - This is the default. The condition appears in the Filtered by link of the report, and in the Report Editor the Change Logic button is displayed. The user can change any column, relationship, or value in the filter.
  • Allow changes to values only - The condition appears in the Filtered by link of the report, and in the Report Editor the View Logic button is displayed. The user can change only the Value field within the condition.
  • Read only, allow no changes - The condition appears in the Filtered by link of the report, and in the Report Editor the View Logic button is displayed. The filter cannot be changed by users.
  • Filter not visible in Viewer - The condition is not displayed in the Filtered by link of the report, and a button is not displayed in the Report Editor. The filter cannot be changed by users.
Use null if empty This option is important only when there is no value at run time specified in the Value field. By default, when the Value field is empty at run time, the criteria defined by this row is ignored, and processing is the same as if this row is not present.

For example, assume the criteria is that the customer's last name starts with a given letter, and the value set in the Value field is param.Letter. If this report runs at a time when Param.Letter has the value "C", this criteria limits the report to contain only instances in which the Lastname property value starts with the letter C. However, if the same rule runs again when the Param.Letter parameter has no value, this criteria is dropped, so instances with any Lastname value (or none) are selected.

In situations where this default behavior is not desirable, select the Use null check box to force the Condition value to become Is Null when the Value value is blank at run time. In the above example, the criteria is transformed to "Lastname is null" — which is different from having no restriction on Lastname.

Ignore case Select this option to have run time comparisons of the Field value and the Value value be case-insensitive. For example, "Smith" matches "SMITH" and also matches "sMiTH".

If selected, at run time " a " matches " A" and is less than " B".

When you do not select this option, tests of the Field value and the Value value occur without case conversion. In this case, " a " is greater than both " A " and also greater than " B ".

CAUTION:
In most cases, do not select this option. Select this box only when necessary to obtain the rows of the report:
  • If your PegaRULES database is hosted by Microsoft SQL Server, comparisons are always case-insensitive. Selecting this option does not affect the report contents, but might increase processing.
  • If your PegaRULES database is hosted by Oracle, IBM Db2 or most database vendor products, selecting this option might affect which rows appear in the report when values occur in mixed case. Conversion to uppercase can significantly slow database processing.
  • Case conversion is meaningful only for properties of type Text, Identifier, or Password. Regardless of database software, case conversion is not needed for numbers, dates, or text that contains only uppercase or lowercase characters.

Filter caption settings

This control lets you specify whether the caption you set for each condition (such as "customer") applies to the left side of the condition ("customer = 'brown'"), or to the entire condition ("customer").

The section Filter conditions to apply AFTER aggregation is displayed only if the report includes a column with a Summarize function, which is also known as an aggregate column. If your report includes an aggregate column, you can add filters that the system applies after calculating aggregate values. By using these filters you can, for instance, display the rows that fall below or between some minimum (severity < 50) or maximum (rating > 75) aggregate value.

Note: If you define filter conditions in this section, you must enter a logical expression in the Filter conditions text box.

For each filter condition, the following fields are available. You do not provide captions for these filter conditions, because they are not displayed in the Report Viewer. The column source does not display either, because it is the aggregate column of the report.

Field Description
Condition Specify a letter (or letters) that uniquely identifies this row, to reference this row in the Logic field. This condition can be as simple as A for the first row, B for the second row, and so on. A condition can have letters and numbers, but no spaces, and you cannot use the words "And" or "Or", as they are used to relate the various filters.
Function Select the aggregation function for the aggregate column on which you want this filter to operate. If the function is COUNT and the column label is "customer", the function option appears here as "COUNT(customer)" to distinguish it from functions related to other aggregate columns in the report.
Relationship Select a logical operator for the comparison condition, such as Is equal or Greater than.
Note: If you select Contains and specify a function as the column value, the filter operator is modified to "=" instead of "LIKE". Use an SQL function in the Column source field instead of the Value field to generate the Contains logic in an SQL statement.
Value Specify one of the following options as a comparison value:
  • A literal constant, formatted in accordance with the property type.
  • A fully qualified property reference to a Single Value property that is present on the clipboard at run time. The Type of this property must match the type of the property in the Column field.
  • A reference to a parameter that is defined in the report's rule, in the format param.name.
  • The name of another Single Value property that is exposed as a column.

Commas correspond to an OR test: If the Value field contains two or more entries separated by commas, the comparison is true at run time if the value of the Column field equals (or is greater than, or is contained in, and so on) any one of the entries.

When the Value field contains a Value List or Value Group property reference, the comparison is true at run time if the value of the Column field is true for any element in the list or group.

When evaluating either of the two Condition values Greater or Greater or Equal at run time, the result is the same as applying the test to the largest value in a list or group. Similarly, when evaluating the Condition values Less or Less or Equal at run time, the result is the same as applying the test to the smallest value in the group or list. The Value List and Value Group options are most useful for other condition values, such as Contains or Starts with.

Additional options might be available:

Control Description
Remove duplicate rows For list reports, when this option is selected, the report discards rows that have duplicate values for the columns selected for the report. This action does not modify the stored data.
Filter by rule resolution For report definitions that are defined on the Rule- class, or a class derived from Rule-, select this check box to restrict the rule instances included to those that satisfy the rule resolution procedures. Circumstancing is ignored.
Filter by application context
For report definitions that are defined on the Rule- class, or a class derived from Rule-, select this check box to restrict report coverage to those in a certain application context. When you select this check box, additional fields are available so that you can set application context filters:
Field Description
Context mode Select one of the available modes to limit the report scope:
  • All Rules in Application
  • All Rules in Application and Frameworks
  • All Rules in Application and Frameworks except PegaRULES
Application name Select the application on which to filter.
Application version Select the application version.

When using the application context filtering option, you can add and sort report results by the values in a hidden column like pyRulesetVersion.

Top/Bottom Rank

For list reports, you can limit the number and type of rows of data that the report returns to those with the highest or lowest values of some property:

  • Display: Choose either Top ranked or Bottom ranked to limit the report to those rows with the highest (top ranked) or lowest (bottom ranked) values of the specified property.
  • Number field: Specify the maximum number of rows to include.
  • Grouping: Choose whether to limit the number of rows in the entire report (Overall), or the number of rows within each group as defined by the Group results check box (For Each Group).
  • Based on: Select the property or function to be used in ranking rows and determining which should be included. To select a function, click the Calculation Builder icon to open the Calculation Builder. For more information, see The Calculation Builder.

For example, for a report that shows the three most recently entered cases for each customer, select the Group results check box to sort the results by customer. In the Top/Bottom Rank section, specify:

Display Top ranked 3 Rows For each group based on .pxCreateDateTime

SQL Server database rule resolution query is slow or times out

For SQL Server databases and report definition rules that have rules resolution enabled, Pega Platform generates a query with an inner join that might result in a slow execution plan or query time out. A more efficient solution is to use an inner merge join for the query. You can configure Pega Platform to use an inner merge join query by setting the following Dynamic system Setting:

  • Setting Purpose : reporting/useMergeHintForRRquery
  • Owning Ruleset : Pega-Reporting
  • Value : True