Creating bands on metrics (custom groups banding)

Elements inside custom groups act like separate and independent filters; they add different WHERE and GROUP BY clauses to the SQL statement generated by the report. The filtering condition can be an attribute qualification as in the previous example, a metric qualification, or other objects. Metric qualifications work like filters on metrics (see Chapter 4, Objects – Facts and Metrics, and Chapter 8, Dynamic Selection with Filters and Prompts, for more details).

I personally use custom groups because they offer a high level of flexibility and may be modified over time, when reporting requirements change, with no need to touch the database schema. As a plus, you can give different formats to different elements.

Another very interesting feature of custom group is the custom banding.

Custom bands are a way to create sets of rows depending on the values of a metric. Typical use can be segmenting customers by purchase brackets or clustering products by number of units sold.

Getting ready

You need to have completed the previous recipe to continue.

How to do it...

In this recipe we are creating a custom group and a report showing the best-selling bikes that sold more than 1000 units, more than 1200, and so on:

  1. Go to My Objects folder and right-click on the empty area to the right, select New | Custom Group and click on OK.
  2. Double-click on the line that says Double-click here or drag an object from the object browser to add a custom group element.
  3. The new element is created and named Custom Group Element1, rename it as Best selling Products.
  4. Double-click on the red colored [Add Qualification] text, now in the lower part of this screen select the fifth radio button labeled Add a Custom Group Banding qualification and click on OK.
  5. Click on the ellipses button next to the Metric textbox and select the Sum OrderQuantity from FactResellerSales metric, confirm by clicking on OK.
  6. Click on the Level… button. In the shopping cart that appears move the Product attribute to the Selected objects list and click on OK.
  7. Open the Banding type drop-down list and pick Banding Points, you will see a row in a white area with a band named Band 1, as shown in the image:
    How to do it...
  8. Click on 1 displayed next to the To header and change it to 1200.
  9. Then click on the 0 value displayed next to the From header and type 1000.
  10. Lastly, click on the Band 1 text and name this band as More than 1000 units.
  11. Click on the Add New Band text.
  12. Band number 2 already has a From value set to 1200 in the lower limit, modify the To value and write 1400.
  13. Rename Band 2 to More than 1200 units and click on Add New Band.
  14. Change upper limit To of the third band to a very high number such as 100000 and name the band More than 1400 units. Click on a white area to confirm the name, the editor should look like the following screenshot:
    How to do it...
  15. Close this pane with the OK button, click on Save and Close, name it as Best selling Products Custom Group and click on the Save button.
  16. Go to My Reports and create a blank new one.
  17. Browse to My Objects in Object Browser and add to rows the Best Selling Products Custom Group.
  18. Go to Public Objects | Metrics and add to columns the Sum OrderQuantity from FactResellerSales.
  19. Click on the Data Explorer shortcut, double-click on the Products hierarchy and then on Product Category and drag the Bikes element to the report filter area.
  20. Run the report in Grid View, observe that we have the three bands each one with its OrderQuantity and a total for the custom group element Best selling Products.
  21. Save this report as 51 Best selling Bikes Bands.

How it works...

The name of the custom group element—Best selling Products—will appear at the top of the first column, then in a hierarchical view, all the names of the bands will appear in a second column.

It's worth noting that lower limits are inclusive while upper limits are not: so the first band in our example is actually between 1000 and 1199, the second between 1200 and 1399, and so on. Adjust the values of the textboxes according to the expected results.

Another aspect that may lead to confusion is that the bands always go from small numbers to big numbers. There is no way to create them in reverse order that is from a higher to a lower value (at least until version 9.3.0).

The Level is actually the GROUP BY clause of the query: is the Level at which we calculate the OrderQuantity before filtering those Products that pass the 1000 threshold. Go to SQL View to see how the HAVING clause is used to restrict the result set.

There's more...

What if we want to sort the banded products by OrderQuantity in descending order? It actually makes sense to have the top bikes first in the report grid. Try this:

  1. In My Objects folder, double-click on Best Selling Products Custom Group to edit.
  2. Right-click on the name of the first element to bring up the context menu, click on Show display options.
  3. Select the second radio button Show only the individual items within this element and click on OK.
  4. Click on Save and Close, go to My Reports.
  5. Open the report number 51 in Design View and browse to Attributes.
  6. Add the Product attribute to rows and run the report.
  7. When the grid appears, right-click on the Sum OrderQuantity from FactResellerSales header and from the context menu select Sort rows by this column | Descending.
  8. Now the bands are in reverse order, save the report as 51 Best selling Bikes Bands DESC.

Exercise 32

Create a new fact: OrderQuantity from FactInternetSales

Create a new metric: Sum OrderQuantity from FactInternetSales

Modify Best Selling Products Custom Group, rename the first element to Best selling Products (Resellers), and create a second element Best selling Products (Internet) with similar bands (1000-1200, 1200-1400, 1400-100000) based on the Sum OrderQuantity from FactInternetSales metric.

Build the report 52 Best Selling Products Reseller and Internet, like the one in the following image:

Exercise 32

Remember to update the schema and to set the custom group element display options.

Note

You can watch screencasts of these operations at:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset