IBM Support

How to properly sort BIRT reports that use grouping

Question & Answer


Question

How can you modify the default BIRT sorting on IBM Rational RequisitePro report items, so that requirements are sorted in the appropriate order?

Cause

The requirement prefix (RPre) report element is a string, and is sorted using a different logic than a user might expect.

For example, requirements FEAT1, FEAT2, FEAT3, FEAT11, FEAT12 would be sorted by default in the following fashion:

FEAT1
FEAT11
FEAT12
FEAT2
FEAT3

You would likely expect to see the requirements sorted in numerical order.
When using grouping in a BIRT table, you will need to insert some custom sorting properties to achieve this result.

Answer

The following steps will cause the report to be sorted in numerical order.

    • This sorting can be achieved through various methods using BIRT.
    • This technote describes one of the methods available for sorting.
    • A sample report is attached which demonstrates the sorting as well as some other BIRT capabilities like report parameters, aggregating data, and grouping.

    1. Modify the data source to include the Tag report element. The Tag can be used for sorting, as it is a numerical representation of the requirement prefix. Set the data type of the Tag element to Integer

    2. Add the Tag element by dragging it in to the table in the BIRT report.

    3. Select the Tag element, and click Properties > Visibility > Hide Element to make the Tag element hidden.

    4. Modify the table grouping by selecting the table, and clicking Groups, then clicking Edit to modify the grouping.

    5. Click the Sorting tab in the editor:


    6. Click Add to add the sort by Tag

    7. Select Tag, and click OK to add the sorting

    8. Now that you have the sorting on the table grouping enabled, you will also want to add sorting to the rest of the table. Click on the table, and go to the Sorting tab and add the Tag, and any other fields that require sorting.




Upon running the report again, the requirements will display in numerical order by tag, however will not yet display in alphabetical order if there are multiple requirement types.

You might see the following:

FEAT1
UC1
FEAT2
UC2

Using the example above, you want to sort the requirement prefixes in alphabetical order. You can add a calculated value to the report which returns the first letter of the requirement prefix:
  1. Double-click the data set, and select Computed Columns




  2. Click New

  3. Create a calculated value with the following properties. The expression uses a BIRT function to return the first character of the requirement prefix. If you want to return more characters, change the number in the expression.

    For example BirtStr.left(row["RPre"],2) will return two characters of the requirement prefix.



  4. Add the SortReq element to the report table, and hide the element using the Visibility property

  5. Modify the grouping again, and add the SortReq field to the top of the list.

    The grouping should now look like this:

Disclaimer

All source code and/or binaries attached to this document are referred to here as "the Program". IBM is not providing program services of any kind for the Program. IBM is providing the Program on an "AS IS" basis without warranty of any kind. IBM WILL NOT BE LIABLE FOR ANY ACTUAL, DIRECT, SPECIAL, INCIDENTAL, OR INDIRECT DAMAGES OR FOR ANY ECONOMIC CONSEQUENTIAL DAMAGES (INCLUDING LOST PROFITS OR SAVINGS), EVEN IF IBM, OR ITS RESELLER, HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.


[{"Product":{"code":"SSSHCT","label":"Rational RequisitePro"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"Reporting","Platform":[{"code":"PF033","label":"Windows"}],"Version":"7.1;7.1.0.1;7.1.0.2;7.1.1","Edition":"","Line of Business":{"code":"LOB45","label":"Automation"}}]

Document Information

Modified date:
23 June 2018

UID

swg21410792