Web Designer
Tutorial 4.1: Master- Detail Report using Groups
Get Started > Tutorial 4: Create Master-Detail Report > Tutorial 4.1: Master- Detail Report using Groups

A master detail report can be created by grouping the details in the Details row of Table data region. For each associated row from the master record, the grouped details are repeated.
Consider that you want to create a report that shows titles and corresponding values of quantity, price, and total price. You also want these details to be categorized according to the customer name. In this case, the details go to the details row of the table, and these details are repeated for each customer.

What You Will Learn

This tutorial guides you through the steps to create a master detail report by grouping a part of data in a Table data region.

Note: This tutorial uses shared data set - CustomerOrders. The shared data sets and shared data sources can be viewed or modified in the Administrator Dashboard. For information on adding shared data sets, see Tutorial 7.1: Add Shared Data Set.

After you complete this tutorial, you will have a report that looks similar to the following.

Access the ActiveReports Web Designer and Add Data Set

  1. On the ActiveReports Server Report Portal, click Create report. 
    The ActiveReports Web Designer opens in the new browser tab.    
  2. From the top right corner of Web Designer, click the Data icon .
  3. Click Add and then from the shared data sets available, select CustomerOrders.
  4. Click Add. The CustomerOrders data set is added to the report.

Report without Grouping

Create Report Layout

  1. Drag and drop Table data region  onto the design area of the report. By default, you have a table with three rows and three columns.
      
  2. To add one more column to the table, click inside the table to display the column handle, and then click the plus sign.

    Now we have a table with three rows and four columns.

Bind Data to Table Data Region

Let us now populate the Table data region with data. The detail part of the report will consist of titles and corresponding values of quantity, price, and total price. 

  1. To fill the data in details row of the table,

  2. Click the dropdown next to the CustomerOrders data set to view fields.
  3. Drag and drop the Title field on the first column, Quantity field on the second column, and Price on the third column.
  4. To add total field in the fourth column of the details row, select the last text box in the details row.
  5. Go to the Properties pane, and select the radio button next to Value property.
  6. Select Expressions... from the drop down and enter the following expression in the Expression Editor: =Fields!Quantity.Value * Fields!Price.Value.

    The table should now look like the following image.

  7. In the header row above the details row, enter the labels for the details as shown.

Preview Report

  1. Click Preview  to view your report in the final output. This is a simple tabular report with details and label for each column. The labels for the details are displayed on the first page of the report.
  2. Exit the preview mode by clicking Back on the top left side of the designer.

Report with Grouping (Master - Detail Report)

Let us add more meaning to the report by adding groups.
We will group the details according to the customer names, and will have the column labels repeated for each group. So, the master part of the table will consist of last name of the customer and the static text for the labels in the detail part.  To do so, let us add two row groups, as described in the following sections.

First of all, delete the Header and Footer rows (these are not required in our report),

  1. Click inside the Table data region to make the row handle appear.
  2. Right-click the row handle and select Remove Header to remove the header row from the table.
  3. Again, right-click the row handle and select Remove Footer to remove the footer row from the table. 

Add Groups and Bind data to the Groups in Table Data Region

  1. To add a group that contains the customer name,

  2. Right-click any text box (cell) in the details row of the table to view options in the context menu.
  3. Go to Group and select Insert Group.
     
    This adds a row group above and below the details row.
  4. In the first text box of the added row group, drag and drop the LastName field as shown.
  5. Right-click a text box in the added row group (above the details row).
  6. Go to Row and select Below.
    Now your table looks similar to the following.

    Note that the table groups are also displayed in the adorner on the right side of the Table data region.
  7. In the row group above the details row, enter the labels for the details as shown.
     
    To group the details for each customer,

  8. From the Explorer , select the Tablix data region.
  9. Click the Group Editor icon  to display row group.
  10. Select Table1_Group1 row group and go to the Properties pane.
  11. In the Group Expressions property, click Show Items and then select Add Item.
  12. Click the radio button to display the fields and select the CustomerID field.

    To obtain the sum of prices for each group,

  13. Go to the last text box of the row group below the details row.
  14. Enter the expression =Sum(Fields!Price.Value*Fields!Quantity.Value in the same way as we added expression in the Bind Data to Table Data Region section.
    The table with bound fields looks as shown.

Add Report Title

  1. Drag and drop a TextBox control  above the table. If required, relocate the table to create space for the text box.
  2. Click inside the text box and enter the text 'Customer Orders (Master Detail Report)'.

Customize the Appearance of Report

Note: You may need to resize and reposition the controls on the report to accommodate data, and for a cleaner look.

  1. To customize the field with the last name,

  2. Select the LastName field.
  3. In the Properties pane, set Font Size property to 12pt.

  4. Set BACKGROUND - Color to Plum from the colors available on Web tab of the color pallet.

    To span the last name field over the table,

  5. Select the cells in the top row group using mouse drag or simply using Ctrl+Click combination.
  6. Right-click the selected cells to view the options in the context menu, go to Cells and select Merge Cells.

    To align the labels,

  7. Select the label Title and from the Properties pane, set the TEXT - Text Align property to Left.

  8. Set the TEXT - Text Align property of Quantity, Price, and Total Price text boxes to Center.

    To make the labels bold,

  9. Go to the Properties pane.
  10. Set the Font Weight property of Title, Quantity, Price, and Total Price text boxes to Bold.

    To add background colors for the detail part,

  11. Select the text boxes of the details row, and the Sum field in the row group below detail row.
  12. From the Properties pane, set the BACKGROUND - Color to Moccasin from the colors available on Web tab of the color pallet. 

     

Preview and Save Report

  1. Click Preview  to view your report in the final output.
  2. Exit the preview mode by clicking Back on the top left side of the designer.
  3. Switch to the File tab and click Save to open the Save dialog box. Enter the report name and click Save Report. You can also provide a description and a revision comment for the report.  
See Also