[]
        
(Showing Draft Content)

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 a sample CustomerOrders data set.

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


Master-Detail Report using Groups Example

Create Databound Table

To create a databound table,

  1. Go to the Data tab and click the drop-down next to the CustomerOrders data set. You can now see all the available fields in the data set.

  2. Enable Select Fields... and then choose the desired fields required in the table.

    Enable Select Fields option

  3. Drag-drop the selected fields onto the design area. A table with its column bound to the fields is created. You can see the Header row and Details row of the table are automatically filled with the data.

    Enable Select Fields option


    Alternatively, you can first drag-drop the Table data region Table Data Region onto the design area of the report and then populate the data by dragging and dropping the fields onto the details row.

  4. We will now add one more column to the table that will display the total field. For this, you need to click inside the table to display the column handle, and then click the plus sign.

    Add column to table

    We will now have a table with two rows and four columns, respectively.

  5. Select the newly added column of the details row and enter the following expression in the Value field, {Quantity} * {Price}

  6. Then lastly, select the textbox above the details row for the total field and enter the text 'Total Price' in it.

    The table is finally created and it would look similar to below.

    Add column to table

Note: The Data Set Name property of the table is automatically set to CustomerOrders data set.

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

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 first name and last name of the customer along with 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 row of the table (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.

    Remove Table Header and Footer

To add a group that contains the customer name,

  1. Right-click any text box (cell) in the details row of the table to view options in the context menu.

  2. Go to Group and select Insert Group.

    Table Data Region with Group


    This adds a row group above and below the details row.

    Table Data Region with Group

  3. Select the first text box of the added row group and set its value as following, {FirstName} {LastName}

  4. Right-click a text box in the added row group (above the details row) to view options in the context menu.

  5. Go to Row and select Below to add a new row for the header labels.

    Table Data Region with Bound Data

    Now your table looks similar to the following.

    Table Data Region with Bound Data

    Note: The table groups are displayed in the adorner on the right side of the Table data region.

  6. In the row group above the details row, enter the labels for the details as shown.

    Entering details for the details row in the Table data region

To group the details for each customer,

  1. From the Explorer Report Explorer Icon, select the Table data region.

  2. From the adorner on the right side of the Table data region, select Table1_TableGroup1 row group, and go to the Properties pane.

  3. In the Group Expressions property, click Show Items and then select Add Item.

  4. Click the radio button to display the fields and select the CustomerID field.

    Select group expressions

To obtain the sum of prices for each group,

  1. Select the bottom-right-most cell of the table and enter the following expression in the Value field, {Sum(Quantity * Price)}

    The table will now look as shown below.

    Table with bound fields

Add Page Header

  1. Go to the Report tab on top of the designer and select Add Header option.

    Add Page Header

  2. Drag and drop a TextBox control Textbox Control in the page header area.

  3. Click inside the text box and enter the text 'Customer Orders (Master Detail Report)'.

Customize the Appearance of Report

Customized Master Detail Report Example

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

  1. Set the BACKGROUND - Color property for the page header of the report to '#f1f1f1'.

  2. Align the text in the textboxes using the TEXT - Text Align (Left, Right, Center, and Justify.) and TEXT - Vertical Text Align (Top, Middle, or Bottom) properties. By default, these properties are set to General and Top.

  3. Set the font size for the text in the page header to '14pt' using the TEXT - Font Size property.

  4. Specify the border properties for the textboxes in the table using the BORDER - Width, Border - Style, and BORDER - Color properties. Set the border values to '0.25pt', 'Solid', and '#f1f1f1', respectively.

  5. Change the TEXT - Format property for the Price field to 'Currency'. This property displays the price values in currency format.

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. Click Save to open the Save dialog box. Enter the report name and click Save Report.