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:
- Double-click the data set, and select Computed Columns

- Click New
- 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.

- Add the SortReq element to the report table, and hide the element using the Visibility property
- Modify the grouping again, and add the SortReq field to the top of the list.
The grouping should now look like this:

Was this topic helpful?
Document Information
Modified date:
23 June 2018
UID
swg21410792