Last week we discussed how to extract Header data in order to create a report model. This week we’ll learn the details of how to create the fields that make up the Header.
There are two ways to create fields.
1. Highlight a field, right click and select Add Field (Figure 8).
2. Right click within the header area, and select Auto Create Fields.
ReportMiner will scan the sample data and identify any changing values within any occurrences of the header. These changing values will be marked as fields.
In our example, the Auto Create Fields feature added five fields. They are now displayed in the Report Browser under the header node. Notice that our new fields are also highlighted in darker purple in the Report Definition Editor (Figure 9). The fields created this way are assigned unique names, such as Field_0, Field_1, and so on.
You can rename a field if needed. Let’s rename our newly created fields to make them more descriptive. We can use any of the three methods described below.
1. A field in the Report Browser, double click and enter the new name
2. Select a field in the Report Browser, right click it and select Rename
3. Select a field in the Report Definition Editor (the selected field is highlighted in yellow), right click, and select Rename from the context menu.
The selected field is always highlighted in yellow in the Report Definition Editor.
We can also change the field’s data type, if needed. In our example, ReportMiner correctly assigned field data types from our sample report (Figure 10).
Creating a Data Region
Now that we created the definition of the Header, let’s look into the main region of the report. As we saw earlier, the main region starts with the Customer Name and then includes Account Number, Contact Name, and, finally, specific order details. Let’s assume that we are interested in extracting only the order details and order items for the respective orders.
Let’s select the order lines, then right click it and select the Add Data region from the context menu (Figure 11).
Figure 11This will add a new Data node in the Report Browser. This new node has no fields at this point (Figure 12).
Figure 12Now we will identify the using appropriate masks. In this case, it’s easy to identify orders as they always start with ORDER ID: at the same position. Place the cursor at the position where the text ORDER ID begins, as shown in the screenshot, and enter ORDER in the pattern text input (Figure 13).
The Report Definition Editor highlights any occurrences of the Data region in report. Remember that we can easily adjust the height of the region by using the Line Count input.
Let’s rename our region Order. Now our report has two regions: Header and Order.
Now, let’s identify the fields making up the Order region. The Order region has two fields – Order ID and Ship Date. Let’s add these fields to the region. If needed, scroll back to the Adding Fields section where we talked about adding fields in the context of a Header region.
Creating a Collection Region
Next, let’s take a closer look at the Order region. Notice that each customer can have one or more orders, and each order may have several order items in it. In ReportMiner terms, we say that the region has a collection of items, or to put it simply, a Collection.
Let’s add order items to the Order. After selecting the Orders node in the model, we select a row underneath the order that represents an order item and then right click it and select Add Data Region from the context menu.
We can identify this region by the repeating pattern of item code. We are going to use a data mask in the text pattern input to match with the item code. To that end, enter Match Any Alphabet three times, followed by a hyphen, and then Match Any Digit five times as shown in Figure 14.
Whenever a node has a collection of items, we need to turn on its Is Collection property as shown in Figure 15. Notice that the appear- ance of the icon for the Item node in the Report Browser changes to help identify this node as a collection. When we add a Collection Data Region via the context menu, the Is Collection property is enabled automatically.
Right click anywhere within our region, and select Auto Create Fields. This creates the Order Number field and the Ship Date field, named Field_0 and Field_1 respectively. Let’s give these fields more user-friendly names. After assigning proper names, the model is completed and looks as shown in Figure 15.
Next week we’ll learn about data statistics and how to save and test a report model.