IBM Support

How to add a 'count' for the number of rows in a list report in the report header.

Technote (troubleshooting)


How to add a 'count' for the number of rows in a list report in the report header.

Resolving the problem

Add a Data Item in Query Explorer and a Layout Calculation or Singleton in the report Header.


  1. Open new list report in Report Studio (this example uses the GO Sales (query) model).
  2. Drag Retailer (from Sales (query) > Retailer) and Quantity (from Sales (query) > Sales) to the work area.
  3. Select the query in the Query Explorer, and from the toolbox, add a data item
  4. From Query Items, drag and drop Quantity, and edit the expression so that it looks like this:
    count([Quantity] for report)
  5. Click OK.
  6. Rename the data item to quantity_count.
  7. This data item can now be used in two ways:
    • As a singleton:
      1. Go back to the page design. From the toolbox add a Singleton to the header
      2. Change the query of the singleton to be the same query as the data item from above
      3. Add the quantity_count data item to the singleton container
    • As a layout calculation:
      1. In the Page Explorer, on Page1, from the toolbox, add a calculation (layout) to the header.
      2. In the Expression Definition, drag quantity_count into the expression and then click OK.
      3. If desired, add a label for the count by adding a Text Item from the toolbox to the right of the quantity_count data item. Enter text: 'Row Count: '
      4. Select the Page object, and set the Query property to the query that contains the dataitem
      5. Set the Properties property to expose the Quanity_count data item (by checking the box beside it).
  8. Run the report.

Note: the result will be returned based on the most granular level, so might return a too high value. If the requirement is the number of rows of the resultset, add an additional aggregation to the calculation, ie. count(total([Quantity]) for report)

Document information

More support for: Cognos Business Intelligence
Report Studio

Software version: 10.2, 10.2.1, 10.2.2

Operating system(s): Platform Independent

Reference #: 1339064

Modified date: 17 December 2009

Translate this page: