Issue
On configuring a report definition with an aggregate column that has the sort order set on it, the value of the sort order for that column changes to n-1 (where ‘n’ is the number of columns) while saving the report definition.
Symptoms and Impact
The sort conditions do not meet the requirements.
Steps to reproduce
- Log in to the Pega application.
- Create a report definition with multiple columns.
- Use the Summarize feature (for example: count, max, min) on any column to make it an aggregate column.
- Provide the sort order as 1 for the aggregate column.
- Provide the sort order as 2 for any other column.
- Save the report definition. The sort order changes to n-1 for the aggregate column.
Root Cause
This behavior is consistent with the current design of Pega code or rules.
The columns present in the ‘GROUP BY’ clause while generating the query must be given first priority for the sort order. Therefore, the sorting of the aggregate column must have the last priority, else it will break the tree view. As a result, it is recommended to set the sorting of the aggregate columns at the end.
The logic was incorrectly set to (n-1) instead of (n). Therefore, when only two columns are present (due to the incorrect logic (n-1); that is, (2-1) = 1)) the sorting is set to 1. As a result, the sort order for the aggregate columns will not change when the value is set as 1 (which is incorrect). When more than two columns are present, due to the incorrect logic, the sort order for aggregate columns will be set as n-1 instead of 1.
For example, when there are only two rows and the sort order for the .pyLabel
Aggregate column is set to 1, the value of the sort order remains unchanged after saving the report definition. Refer to the following image:
However, the sort order should have been 2 for the .pyLabel
aggregate column.
When there are more than 2 rows and the sort order is set to 1 for the ‘.pyLabel’ aggregate column, after saving the report definition, the value of the sort order for the aggregate column is changed to n-1 (that is, when n = 3; n-1 is 3-1 = 2). Refer to the following image:
The sort order should have been set to 3 for the .pyLabel
aggregate column. Refer to the following image:
The following table displays the expected result,
Column Source | Sort Order |
---|---|
.pyLabel |
3 |
.pyOrganization |
1 |
.pyRuleSetName |
2 |
Solution
Perform either of the following to resolve the issue:
- Do not set the sort order value for the Aggregate column.
- Update to either of the following:
- Pega 24.1.3
- Pega 24.2.2