Using Dynamic Resources
When you drag view elements from the Resource View panel to analyze data of a report, sometimes you may find that the view elements that have been predefined in the business view cannot meet your requirements, in which case you can create dynamic resources including formulas and aggregations and use them in the report to get the desired data. Then when you save the report, the dynamic resources will be saved along with the report as its resources.
Dynamic resources are report tab level resources, which means they are only available to the report tab for which they are created.
A Logi JReport Live license for Logi 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.
Below is a list of the sections covered in this topic:
Creating and Using Dynamic Formulas
You should have some knowledge of the formula syntax before you can successfully compose a formula with no errors. To learn the formula syntax, refer to Formula Syntax.
To create a dynamic formula:
- In the Resource View panel, expand the Dynamic Resources > Formulas node, then select <Add Formula…>. The Formula Editor appears.
- Enter a name for the formula in Formula Name text field.
- By default, Logi JReport will decide whether the formula can be used as an aggregation object, and if not, the formula will be used as a detail object. You can specify to use the formula as a detail, group, or an aggregation object, by selecting the corresponding view element type from the Use As drop-down list on the toolbar.
Whether a dynamic formula can be used as a certain type depends on the following rules:
- Any formula can be used as Detail.
- Any formula that references a DBField and not an aggregation can be used as Group.
- A formula that refers only to aggregations can be used as Aggregation. For example, there are two aggregations Sum_Total and Sum_Quantity, and you can create a formula
@"Sum_Total" / @"Sum_Quantity"
and use it as an aggregation. - A formula that follows the custom aggregation expression can be used as Aggregation.
- Compose the formula by selecting the required fields, functions and operators from the Fields, Functions and Operators boxes. You can also write the formula by yourself in the editing box.
For details about the functions and operators, refer to Built-in Functions and Operators.
- Select the Check button to check whether or not the syntax of your formula is correct.
- When done, select the OK button to create the formula.
Once a dynamic formula is created, you can then drag it from the Resource View panel to the desired position in the report for data analyzing. The formulas can also be used to control object properties if you are an advanced user and provided that the Use Dynamic Formula in Property is checked on the Report menu.
If you want to further edit an existing formula or remove any formula that is not required, right-click the formula and then select the corresponding command on the shortcut menu. However, if the formula has been used in the report or referenced by another formula, it cannot be deleted.
Creating and Using Dynamic Aggregation Objects
In Page Report Studio, you can also create dynamic aggregation objects by mapping them to the available resources which include group objects, detail objects in the current business view and the dynamic formulas that have been created in the report.
To create a dynamic aggregation object:
- In the Resource View panel, expand the Dynamic Resources > Aggregations node, then select <Add Aggregation…>. The Add Aggregation dialog appears.
- In the Aggregation Name text field, specify the display name of the aggregation object.
- Select the button next to the Mapping Name text field. In the Select Source dialog, specify a field or a formula on which the aggregation object is based.
- From the Aggregate Function drop-down list, specify the aggregate function for the aggregation object.
- When done, select OK to create the aggregation object.
You can also create a dynamic aggregation object on a dynamic formula. To do this:
- In the Resource View panel, right-click the formula in the Dynamic Resources > Formulas node, then select Add Aggregation from the shortcut menu.
- In the Add Aggregation dialog, specify the display name of the aggregation object and the aggregate function as required.
- When done, select OK.
Once a dynamic aggregation object is created, you can then drag it from the Resource View panel to the desired position in the report for data analyzing.
For any dynamic aggregation object, you can further modify if needed. To do this, right-click the aggregation object and select Edit from the shortcut menu. Then in the Edit Aggregation dialog, edit the aggregation object as required.
For dynamic aggregation objects that are on longer required, you can remove them. To delete an aggregation object, right-click it and select Delete on the shortcut menu. Aggregation objects that have been used in report cannot be deleted.
Notes:
- You can only use JDK (not JRE) to compile formulas created in Logi JReport and save a dynamic formula with no errors into a report.
- Currently, global variables are not supported in dynamic formulas.
- When formulas reference display names or mapping names, the names should not contain any of below characters if the names are not quoted by double-quotation marks "":
"~", "`", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "-", "+", "=", "{", "}", "[", "]", "|", "\\", ":", ";", "\", " ' ", "<", ",", ">", ".", "?", "/"
Examples:
- Expression @Customer#; will cause a syntax error. But @"Customer#" is ok.
- If a field has the display name Category.Measure, when adding it to a formula, quote it as "Category.Measure" or "Category"."Measure".
- Now in Logi JReport, the display names of objects in a category in a business view cannot be duplicated. When you choose to create a dynamic formula/aggregation object on an object which was created in a previous version and it has the same display name as another object, you will be prompted with a message asking you to give a new name for the object in Logi JReport Designer first.