官术网_书友最值得收藏!

Summary filter and detail filter

Business owners need to see the sales quantity of their product lines to plan their strategy. They want to concentrate only on the highest selling product for each product line. They would also like the facility to select only those orders that are shipped in a particular month, for this analysis.

In this recipe, we will create a list report with product line, product name, and quantity as columns. We will create optional filter on Shipment Month Key. Also, we will apply correct filtering to bring only the highest sold product per product line.

Getting ready

Create a new list report based on GO Data Warehouse (query) package. From the Sales (query) namespace, bring Product | Product Line, Product | Product Name, and Sales fact | Quantity as columns.

Getting ready

How to do it...

  1. We will start with adding the optional filter on shipment month. To do that, click anywhere on the list report on Report Page. Select Filters from the toolbox.
  2. In the Filters dialog box, add a new detail filter. Define filter as:
    [Sales (query)].[Time (ship date)].[Month key (ship date)] = ?ShipMonth?
  3. Set the usage to Optional.
    How to do it...
  4. Now we will add a filter to bring only highest sold Product per Product line. To achieve this, select Product line and Product name (Ctrl+select) and click on the Group button from toolbox.

    This will create grouping shown as follows:

    How to do it...
  5. Now select the list and click on Filter button again. This time go to the Summary filters tab and add a new filter.
  6. Define the filter as: [Quantity] = maximum([Quantity] for [Product line]).
  7. Set usage to Required and set the scope to Product name.
    How to do it...
  8. Now run the report to test the functionality. You can enter 200401 as Month Key as that has data in the Cognos supplied sample.

How it works...

Report Studio allows you to define two types of filters. Both work at different grain and hence have different applications.

Detail filter

The detail filter works at the lowest level of granularity in selected cluster of objects. In our example, this grain is the 'Sales entries' stored in the 'Sales fact'. By putting a detail filter on shipment month, we are making sure that only those sales entries which fall within the selected month are pulled out.

Summary filter

In order to achieve the highest sold product per product line, we need to consider the aggregated sales quantity for the products.

If we put a detail filter on quantity, it will work at sales entry level. You can try putting a detail filter of [Quantity] = maximum([Quantity] for [Product line]) and you will see that it gives incorrect results.

So, we need to put a summary filter here. In order to let the query engine know that we are interested in filtering sales aggregated at product level, we need to set the SCOPE to Product name. This makes the query engine calculate [Quantity] at product name level and then allows only those product names where the value matches maximum([Quantity] for [Product line]).

There's more...

When you define multiple levels of grouping, you can easily change the scope of summary filters to decide the grain of filtering.

For example, if you need to show only those products whose sales are more than 1000 and only those product lines whose sales are more than 25000, you can quickly put two summary filters for [Quantity] with the correct Scope setting.

Before/After aggregation

The detail filter can also be set to apply after aggregation (by changing the application property). However, I think this kills the logic of detail filter. Also, there is no control on the grain at which the filter will apply. Hence, Cognos sets it to before aggregation by default, which is the most natural usage of the detail filter.

See also

Please read the "Implementing IF THEN ELSE in filtering" recipe in this chapter.

主站蜘蛛池模板: 湟源县| 墨竹工卡县| 文水县| 沽源县| 罗定市| 公主岭市| 永川市| 新竹县| 安丘市| 桓台县| 汉寿县| 兴义市| 弥勒县| 南澳县| 浙江省| 阿拉善左旗| 林西县| 阳新县| 泗水县| 呼图壁县| 黄梅县| 桂阳县| 灵宝市| 岚皋县| 彭阳县| 高淳县| 彰武县| 儋州市| 仁化县| 麦盖提县| 塔城市| 拜城县| 华阴市| 石渠县| 宣城市| 嵊泗县| 宁河县| 小金县| 辽源市| 南靖县| 凌源市|