### Using cube elements

After a report set has been built and published to JReport Enterprise Server, you can open it in JReport Web and use the Resource View panel to analyze data of any report in the report set by dragging cube 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 cube 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 cube elements. These examples are based on the WorldWideSales report cube in Data Source 1 of the SampleReports catalog. The report cube contains thirteen dimension objects (City, Country, Customer Name, Region, State, Territory, Sales Month, Sales Quarter, Sales Year, Category, Product ID, Product Name, and Product Type), eleven detail information objects (Address 1, Country, Customer Name, CustomerCityStateZip, Phone, Cost, Discount, Order Date, Quantity, Total, and Unite Price), and three measure objects (Total Cost, Total Quantity, and Total Sales). Total calculates the value of the formula ("Unit Price" * Quantity - "Unit Price" * Quantity * Discount/100), Total Sales defines an aggregate function Sum on the formula Total, Total Cost is Sum on Cost, and Total Quantity is Sum on Quantity.

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

#### Example 1: Analyzing a standard banded report

1. In JReport Web, design a standard banded report titled Sales in China on WorldWideSales, which shows the fields Product ID, Country, Product Name, Unit Price, Quantity and Discount, and applies the ClassicBlue style. See the report.

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', and then click OK to confirm. See illustration.

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

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

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

   See the result.

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 report cube the banded object uses will be shown in the panel.
2. From the Resource View panel, drag the detail information object Total in the Orders Detail category to the detail panel of the banded object. See illustration.

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

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

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. See illustration.

   Now, we can see the same report with an entirely different view of the data. See the result.

#### Example 2: Analyzing a crosstab report

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

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 report cube the crosstab uses will be shown in the panel.
3. Drag the dimension object Region in the Customers category from the Resource View panel to the crosstab until a blue line appears indicating the group level of the dimension. See illustration.

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

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

5. Then we would like to see the territory information for the EMEA region. Click in the EMEA header and we will drill down to the next lower level based on the hierarchy defined in the report cube which in this case is Territory. See the result.

   Using the same way, we can further drill down to the country, then the city levels which have been defined in the hierarchy to get detailed sales information in each city.

#### Example 3: Analyzing a table report

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

1. Design a table report on WorldWideSales, 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 NAME = 'Decaf' to the table (see Example 1 for details on filtering).

   See the result.

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

1. Click the Resource View button on the View toolbar, then resources of the report cube 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. See illustration.

   The report result will be regenerated. See the result.

   Note: 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 > Configure DHTML Profile > Properties > Default Properties 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 information object Total in the Orders Detail category to the header Product Name until the label Product Name is highlighted in a blue background. See illustration.

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

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

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

   The report result will be regenerated. See the result.

   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. See illustration.

   We can see that order of the columns changes. See the result.

Notes:

- When you are using a report cube, the records will be fetched based on the query which contains the report cube in JReport Designer; while for a business cube, there is no predefined query and you will fetch records from the data source using dynamic SQL.
- To use the Resource View panel so as to add cube elements to the report, you should make sure that this ad hoc feature is enabled in the specified DHTML feature profile. This setting can only be made by administrators.