Query Portion of the List Report Sample

The query portion of the report defines the data in the report.

For more information about the queries element, see Queries Element and queries.

The following is the XML for the queries element in this list report sample.


<report xmlns="http://developer.cognos.com/schemas/report/7.0/"
	expressionLocale="en-us">
  <modelPath>/content/package[@name='GO Sales and Retailers']
	  /model[@name='model']</modelPath>
 <queries>
  <query name="Query1">
   <source>
    <model/>
   </source>
   <selection>
    <dataItem aggregate="none" name="Product name">
     <expression>[gosales_goretailers].[Products].[Product name]</expression>
    </dataItem>
    <dataItem aggregate="total" name="Quantity">
     <expression>[gosales_goretailers].[Orders].[Quantity]</expression>
    </dataItem>
   </selection>
  </query>
 </queries>
 <layouts>
  ...
 </layouts>
</report>

Notes About the Query Portion of the Report

  • You must define the name attribute on the query element. The value of the name attribute must be unique. The query name is used to relate the layout portion of the report to the query portion.
  • The query must contain a dataItem element for each data item.
  • The dataItem elements must be unique within each query.

    Use the name attribute to specify a name for each dataItem. This list report queries the data items Product name and Quantity.

  • Add an expression element to the dataItem element.

    In its simplest form, an expression is a reference to a query item in the model, and must appear in the format [namespace].[query_subject].[query_item].

  • Add an aggregate attribute to each data item.

    In this sample, Product name is not a column that you want to summarize, and so the aggregate attribute is set to none. Because you want to know the total quantity ordered for each product, the aggregate attribute for Quantity is set to total. For more information about aggregates, see Summarize Data.

  • In this report, the values that appear under the Quantity column represent the total quantity ordered for each product.

    This summarization occurs by default because the selection element has an autoSummary attribute that defaults to true.