IBM Support

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

Troubleshooting


Problem

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.
Steps:

  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)

[{"Product":{"code":"SSEP7J","label":"Cognos Business Intelligence"},"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Component":"Report Studio","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"10.2.2;10.2.1;10.2","Edition":"","Line of Business":{"code":"LOB10","label":"Data and AI"}}]

Document Information

Modified date:
15 June 2018

UID

swg21339064