The Calculation Builder can be invoked in several places in the Report Viewer, Report Editor, and Report Definition rule form – wherever you can select an SQL function as well as a literal value or column name. You can build nested expressions in the Calculation Builder by using an SQL function as the parameter value for another SQL function.
Pega 7 Platform provides a large number of standard SQL function templates: see Standard SQL function rules for a descriptive list. If none of the standard rules fit the needs of your report, you can create your own Function Alias rule. See About Function Alias rules.
The Calculation Builder icon appears wherever it is available. Click the icon to open the form.
When the Calculation Builder appears, it displays a single field where you can select an SQL function to use. Type the first few characters of the function you want, or use the down-arrow to display a list of available functions. Standard functions appear first, followed by any custom functions application developers have added.
When you select a function, a description of the function and its use appears, together with prompts for any parameter values required.
Note: When entering parameter values for any function, you must be careful to specify a literal value, property, or SQL function of the correct data type.
If you use a function that compares date values, you can compare a date column using one of the following:
Click Apply Changes to finish defining the function, or Cancel to close the Calculation Builder without defining a function.
Note: While expressions using SQL functions can be nested, application performance may degrade if you use highly-nested SQL functions. Consider creating custom SQL functions that contain highly complex logic.
Also, if you have an SQL function that includes CASE WHEN logic, and you want drill-down in charts to work properly, define your SQL function to return a NULL value instead of 0 when a condition fails.
The SQL functions shown in the Data Explorer and listed when you click the Calculation Builder icon is change if a data transform named pyReportEditorFunctions is available for the primary class of the report. This data transform rule generates a Code-Pega-List which specifies a list of SQL functions to be shown, using the function names. The system populates labels and data types at run time. If pyReportEditorFunctions returns a null list, the Calculations tab does not appear in the Report Editor's Calculation Builder. Developers always see the full list of functions when working directly with the Report Definition.
To provide a customized list for a report:
This process creates a single function in the Calculation Builder. Repeat as needed to assemble the full list of functions to display.
Whenever possible, optimize the properties you want to use in your reports. Reporting on unoptimized properties causes a performance drain on the system. If you create reports using unoptimized properties, you will see warning messages in the Report Editor or the Report Definition itself.
On SQL Server, there is a limitation to the size of the value that a Report Definition can report on using the Calculation Builder to get values out of the BLOB (that is, from an unoptimized property). If a value is greater than precision 18, scale 6, SQL server returns an error.