### Using view elements

After a report has been built and published to JReport Server, you can open it in Page Report Studio and use the Resource View panel to analyze data of the report by dragging view elements from the panel to the component (banded object, table or crosstab) in the report, provided that the data objects used by the component can be converted to corresponding view elements (see the note in Analytic reporting for details).

Tip: To display the Resource View panel, click Menu > View > Resource View or the Resource View button on the View toolbar. You can use the search bar at the top of the panel to search for any desired resource in a fast and convenient way.

The following examples show how to analyze reports using view elements. These examples are based on the business view WorldWideSalesBV in Data Source 1 of the SampleReports catalog.

- Example 1: Analyzing a banded report
- Example 2: Analyzing a crosstab report
- Example 3: Analyzing a table report

#### Example 1: Analyzing a banded report

1. In Page Report Studio, design a banded report titled Sales in China on WorldWideSalesBV, which shows the fields Product ID, Country, Product Name, Unit Price, Quantity, and Discount, and applies the ClassicBlue style.

First, we will apply a filter to the banded object to narrow down data scope.

1. Click the Filter button on the Analysis toolbar. In the Filter dialog, define the filter as COUNTRY = 'China'.

We want to further sort the banded object by Product Name ascending.

1. Right-click any of the Product Name values and select Sort > Ascend from the shortcut menu.

2. As the banded header panel holds no data, we can hide it by right-clicking it and selecting Hide from the shortcut menu.

   Now the report shows as follows:

Next, we will add the Total field to the banded object and group by the City field.

1. Click the Resource View button on the View toolbar, then resources of the business view the banded object uses will be shown in the panel.
2. From the Resource View panel, drag the detail object Total in the Orders Detail category to the detail panel of the banded object.

3. Drag the group object City in the Customers category to the banded page header panel, when a blue line appears, release the mouse button.

4. Finally, drag the aggregation object Total Sales in the Orders Detail category to the group footer panel.

5. We can now analyze the data in various ways. For example, if we want to see the sales by category instead of city, right-click on any of the City fields and select Drill To > Category from the shortcut menu, then we can see the same report with an entirely different view of the data.

#### Example 2: Analyzing a crosstab report

1. Design a crosstab report on WorldWideSalesBV showing product sales information with Product Type (Ascend) as the column field, Category (Ascend) as the row field, and Total Cost as the aggregate field. Apply the ClassicBlue style to the crosstab.

First, we want to replace the product type information with region information, and display the total sales of each product category in each region.

1. Remove Product Type from the crosstab by pointing to the header Product Type (Decaf or Regular), then dragging it outside the report page. A message box will prompt you whether or not to remove the field. Click OK to confirm, and we can see that the crosstab no longer contains the Product Type information.
2. Click the Resource View button on the View toolbar, then resources of the business view the crosstab uses will be shown in the panel.
3. Drag the group object Region in the Customers category from the Resource View panel to the crosstab until a blue line appears indicating the level of the group.

4. Drag the aggregation object Total Sales in the Orders Detail category to the aggregate area of the crosstab.

   Now the total sales of each product category in each region is displayed.

5. Then we would like to see the country information for the Europe, Middle East, Africa region. Click in the Europe, Middle East, Africa header and we will drill down to the next lower level based on the hierarchy defined in the business view which in this case is Country.

   Using the same way, we can further drill down to the State, then the City levels which have been defined in the hierarchy to get detailed sales information in each city. For more details about drilling, refer to Automatic drilling.

#### Example 3: Analyzing a table report

For a table, you can analyze its data in the same way as for a banded object. Furthermore, Page Report Studio provides some analysis methods specific for tables.

1. Design a table report on WorldWideSalesBV, which shows the fields Product Type, Country, Product Name, Unit Price, Quantity and Discount, and applies the ClassicBlue style.
2. Add a filter COUNTRY = 'China' AND PRODUCT TYPE = 'Decaf' to the table (see Example 1 for details on filtering). The table displays as follows:

For a table, we can insert a column (or row for horizontal table) at a specific position. So next, we will insert the group object City into the table.

1. Click the Resource View button on the View toolbar, then resources of the business view the table uses will be shown in the panel.
2. Drag City in the Customers category from the Resource View panel to the boundary between the first column (Product Type) and the second column (Country) in the table until a blue line appears. Release the mouse button and a message will prompt you whether or not to insert the group field, click OK to confirm.

   The report result will be regenerated.

   Tip: When you add a column to a table, if the width of the table exceeds the defined page size, you will be prompted whether to allow JReport to adjust the page size automatically so as to place the column. Click Yes in the message box to have the page size adjusted, or No to make the columns in the table compressed. Also, If you do not want to display the message in future, check Don't prompt the message again in the message box, or uncheck Always Prompt Whether to Adjust Page Size Automatically in the Profile > Customize Profile > Page Report Studio > Properties > Default tab. If you choose not to show the message box again, when the table width exceeds the defined page size, JReport will always adjust the page size automatically.

Next, we want to show the total information and remove the product name information. This can be done with a single drag-and-drop.

1. Drag the detail object Total in the Orders Detail category to the header Product Name until the label Product Name is highlighted in a blue background.

   Now, the total value for each record will be generated.

As a table column can contain more than one field, next, we will add the aggregation object Total Sales to the Total column.

1. Drag Total Sales from the Resource View panel to any value in the Total column.

   The report result will be regenerated.

   Here 182,298.76 is the sum of all total values. In this way, the title for the added field will not be automatically created.

At last, we want to change the order of the Total and Discount columns in the table.

1. Drag the label Total to the right of the Discount column, when a blue line appears along the right boundary of the Discount column, release the mouse button.

   We can see that order of the columns changes.

Notes:

- A JReport Live license for JReport Server is required in order to use this feature. If you do not have the license, contact your Jinfonet Software account manager to obtain it.

- When using a business view, the records will be fetched from the data source using dynamic SQL.
- To use the Resource View panel so as to add view elements to the report, you should make sure that this ad hoc feature is enabled in the specified Page Report Studio feature profile. This setting can only be made by administrators.