Script Of User-Defined Field

<< Click to Display Table of Contents >>

Current:  Script 

Script Of User-Defined Field

Previous pageReturn to chapter overviewNext page

A user-defined field refers to the creation of a new field in the edit interface of the data set. The scope is the current data set. This field can be used by all dashboards that use the query. In the metadata area interface, right-click and select Add Expression, enter the field name, select the data type, and add the script language to return the field content. The script cannot use the aggregate function. After creation, you can drag and drop the dimension to the dimension. ) Under the node or under the Measure node.

 

Creation Method

In the metadata area (in the red area in the figure below), the user can create his own data segment that exists only in the current data set and does not exist in other data sets of the same type. In the metadata area, click the More button after the field and select New Expression to open the Expression dialog.

script1

 

Detailed introduction

In the open dialog box, the user can enter the script in the script area of the following figure to realize the creation of the data segment. When you create a data segment in a data set, you can call various functions provided under the Utilities folder, but you cannot use the aggregate functions provided under the Aggregation folder. Detailed description of the function see Top Level Scope Functions.

script2

[Text] set the name of data segment.

[Name type] Set the data field type.

 

Application example 

If SALES data segment exists in the metadata area, as shown in the following image.

script4

When the user needs to add 1000 to every data in SALES field, the new field can be created by script. Suppose that the name is SALES2 ,set data type "Float", only by clicking SALES column, then add +1000 after the column, the content of script is col['SALES']+1000; as shown in the image below.

script5

The SALES2 field is generated under Measure Node, as shown in the image below.

script6