<< Click to Display Table of Contents >> Create Expression |
![]() ![]() ![]() |
Expressions can be divided into detail expressions and dimension expressions.
❖Create Expression
Open the binding interface of any component, that is, open the query list, click the More button in the upper right corner of the query list to open more menus, select the type of data segment you want to create, as shown below:
Select New Expression to open the expression dialog as shown below:
[Name] Set the name of the data segment.
[Data Type] Set the type of data segment.
[SQL expression] When the user selects this item, the SQL statement is supported.
Basic syntax: A function consists of a function name and parentheses, such as Sum(). The data consists of the field name and col[''], such as col['sales']. Computed fields also support calculation of symbols such as addition, subtraction, multiplication, and division.
•Dimension expression
A dimension expression is an expression that is used as a dimension. When defining such expressions, the data types used are generally non-numeric types such as characters, strings, booleans, or date classes. Other fields can be referenced in the expression. For example, put the city and city codes together; or extract only the city information from the field that contains the city and code information. No aggregate functions can be used in this expression.
➢For Example
Suppose there is a dimension data segment for the market distribution. When the user needs to add the suffix "sales" to each region, it can be realized by a dimension expression. In this case, it should be a JS expression, that is, the SQL expression is not checked, as shown below. Shown as follows:
As shown in the following table, the market sales data segment is implemented by creating a new dimension expression.
•Detail expression
A detail expression is an expression used as a measure. When defining such expressions, the data types commonly used for metrics are used: various numeric types. You can reference other fields in an expression, and you can do four arithmetic operations. For example, multiply the sales price field and the sales quantity field to return the total number of sales. No aggregate functions can be used in this expression.
➢For Example
Suppose there are two data segments, one is SALES and the other is PROFIT. When the user wants to calculate the cost of the product, it can be realized by the detail expression. The content of the script is the difference between the two data segments. By default, SQL is checked. The expression needs to be unchecked again at this time, as shown below:
As shown in the following table, the cost data segment is implemented by creating a new detail expression. When creating a new detail expression, modify the name to “cost”.