Defining Expression Attributes
In addition to creating model attributes by directly mapping fields of the physical view, you can also define expression attributes. Expression attributes are attributes that are derived from table columns. You can use derived attributes in the same way as any other model attribute, e.g., in reports, worksheets, hierarchical overlays, etc. (See Design Considerations for more information on hierarchy).
To define an expression attribute, follow the steps below:
1. Right-click on an entity or attribute in the logical model, and select 'Create expression' from the context menu.

This opens the 'Formula' dialog box.

2. In the 'Attribute Name' field of the 'Formula' dialog box, specify a name for the new attribute.
3. In the 'Return Data Type' menu, select the data type of the value returned by the defined expression.

4. Click the 'Edit' button to open the Script Editor.
5. Enter the expression to define the new attribute. (No return keyword is necessary.) The expression should use the appropriate SQL syntax for the underlying database.
6. Click 'Check' if you want Style Studio to check the syntax of the specified SQL expression.

7. Click the 'Save and Close' button.
8. Select 'Aggregate Formula' if the specified expression contains aggregation functions such as COUNT, AVG, SUM, etc., or other database-specific aggregation functions. This will ensure that generated queries include an appropriate GROUP BY clause.
9. Select 'Parseable' if you want VPMs to be able to hide this field based on its component fields. For example: a VPM hides the 'price' column for certain roles, and an expression 'revenue' is defined as 'price' multiplied by 'quantity'. The 'revenue' column will also be hidden for those same roles, as long as it is marked 'Parseable'.
10. Click 'OK' to exit the 'Formula' dialog box. The new expression attribute will appear alongside the existing attributes under the selected entity.
In this example, you will add a new expression attribute to the sample Order Model. The attribute will represent the total price of a particular product's stock (i.e., product price * number in stock).
1. Open the Asset panel. Expand the 'Data Source' node and the 'Orders' data source.
2. Double-click on the 'Order Model' to open the model for editing.
3. Right-click the 'Product' entity in the logical model, and select 'Create expression' from the context menu. This opens the 'Formula' dialog box.
4. In the 'Attribute Name' field, enter “Cost of Stock” as the name of the new attribute.


5. Click the Edit button to open the Script Editor, and enter the following expression:
field['SA.PRODUCTS.PRICE'] * field['SA.PRODUCTS.NUMBER_INSTOCK']
Note: You can double-click the field names in the 'Properties' list to add them to the expression (without typing).

6. Click the 'Save and Close' button.
7. Select 'Double' or 'Float' from the 'Return Data Type' menu.
8. Click 'OK' to exit the 'Formula' dialog box.

The new expression attribute 'Cost of Stock' now appears alongside the other attributes of the 'Product' entity. It is marked with an 'f' symbol, which indicates a formula field.
To modify an existing expression attribute, right-click the attribute and select 'Edit expression' from the context menu. This opens the 'Formula' dialog box, where you can make the desired modifications as discussed above.
| << Customizing the Browse Data List | © 1996-2013 InetSoft Technology Corporation (v11.4) | 4.4.2 Auto-Drilldown >> |