Time for action – modifying functions and page breaks

Follow these steps to modify functions and page breaks:

  1. If we pay attention to the values being reported by our report's functions, we will see that the calculations are not being correctly performed by the group. In order to fix this, we should make the following modification:
    • Reset on Group Name = GroupCountry
  2. We can now perform a preview to see that the calculations are being performed correctly.
  3. We will now configure our report so that each country begins on a new page. We will go to the Structure tab, navigate to Master Report | Group, and make the following modification:
    • Style.pagebreak-after = true

What just happened?

We configured the functions of our report to correctly perform their calculations on a per-group basis, and then configured the Group section so that each new country begins on a different page.

Learning more about groups

A basic requirement for creating groups is that the data set should be ordered according to the criteria that will be used to create the groups. This is why our SQL query contains the statement ORDER BY country.country.

If our data set were not ordered by country, we could end up with a data set like the following:

Learning more about groups

In this case, PRD would create the following groups:

Learning more about groups

This is because PRD creates a new group when the value of the grouping criteria changes.

PRD also provides a UI to manage groups. To access the UI, go to the Structure tab, right-click on the Group node, and select the Edit Group... option.

Learning more about groups

The following fields will appear:

  • Name: The name of the group
  • Available Fields: The fields we can use as grouping criteria
  • Selected Fields: The fields currently being used as grouping criteria
    Learning more about groups

The Learning more about groups buttons are used to move different grouping criteria up or down in the hierarchy.

If we need to create a group with more than one grouping criteria, for example, country and city, we should configure our group as follows:

Learning more about groups

Have a go hero

Now that this chapter is finished, we will invite you to create your own report, in which you will be able to apply some of the things we have seen so far. The first page of the report we are inviting you to create should look like the following:

Have a go hero

And the second page of the report should look like this:

Have a go hero

The steps you should be roughly following are as follows:

  1. Create a new report and save it as the following: 06_Adding_Groups_Plus.prpt.
  2. Create a new JDBC data set and configure it to use the Sakila database.
  3. The SQL query you should use is the following one:
    SELECT LEFT(customer.last_name,1) as letter, 
    CONCAT(customer.last_name,', ',customer.first_name) as customer_name,
    LCASE(customer.email) as email
    FROM customer
    ORDER BY letter
  4. Enable and configure the Group Header and Group Footer sections. This is to be repeated on each page.
  5. Create the general layout of the report.
  6. Configure the Group section of the report so that it groups customers according to their letter fields.
  7. Configure the Group section so that each letter begins on a new page.

Pop Quiz – positioning hierarchy and groups

Q1. Which of the following affirmations are true?

  1. When designing our report in PRD, if two or more objects overlap, they will always be colored red to indicate to us that we should separate them.
  2. The Send Backwards option sends the selected object to the bottom of the positioning hierarchy.
  3. It is possible to perform groupings on more than one criterion.
  4. In order to have a function perform its calculations by group, we should place the name of the field on the Reset on Group Name field by which we wish the grouping to be done.
..................Content has been hidden....................

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