Leverage visualization to assign the result of tag calculations as the tag value. This topic provides guidance on creating a compute tag using rules.
Prerequisites
Before you create an offline tag using rules, you must first establish the corresponding entity. For more information, see Create and Manage Entities.
Procedure
On the Dataphin home page, navigate to the top menu bar and select Tag > Tag Workbench.
Select Project from the top menu bar.
In the left-side navigation pane, choose Tag Processing > Offline Tag.
On the Offline Tag page, click the Project Tags tab. Then, under the Project Tags tab, click Add Tag.
In the Add Offline Tag dialog box, select Compute Tag.
Configure the Basic Information for both Business Attribute and Technical Attribute in Step 1 of the new compute tag setup.
Business Attribute
Parameter
Description
Tag Name
Enter the tag name. Chinese, English, numbers, and underscores (_) are allowed, within 64 characters.
Entity-Entity ID
Select the entity-entity ID to be defined according to business needs.
Tag Type
The tag type classifies tags according to the processing method.
Attribute Tag: Used to describe objective facts and is the most basic and common tag for describing entity profiles, such as gender and name tags.
Statistical Tag: Generated after statistical calculation based on entity behavior or basic attributes according to business needs, such as the purchase amount tag for the last 7 days.
Predictive Tag: Predictive tags predict entity characteristics or behavior based on algorithm models, such as predicting the user's resident province tag.
Composite Tag: Generated by setting specific rules to combine and process tags, such as consumer segmentation tags.
Compute Tag: Generated by mixed calculation processing of different tags, such as gross profit margin and income level.
Timeliness
Timeliness describes the update frequency of tags as they change over time, divided into dynamic and static, with dynamic selected by default.
Static: Generally describes the inherent characteristics of an entity and usually does not change over time, such as gender and name tags.
Dynamic: Needs to be dynamically updated over time to ensure tag validity, such as the order amount tag for the last 7 days.
Owner
Select the owner of the tag. The current user is selected by default.
Tag Description
Enter a brief description of the tag, within 1000 characters.
Technical Attribute
Parameter
Description
Tag Code
The tag code is a globally unique identifier. For example, when there are tags with the same name in the service, it helps you locate specific tags. It must start with a lowercase letter and allows lowercase English letters, numbers, and underscores (_), within 64 characters.
Tag Update Method
Supports Periodic Update and Manual Update.
Periodic Update: Automatically updates the tag at certain time intervals.
Manual Update: Updates the tag through manual operation.
Click Next.
On the new Processing Logic page for compute tags, you can configure the Processing Logic settings specific to the compute tag.
Parameter
Description
Version Number
Enter your tag version number name, default
V1. Allows letters, numbers, underscores (_), hyphens (-), and half-width periods (.), within 64 characters.Value Type
You can choose from string, long integer, double precision floating point, date, Boolean, and decimal. The default for decimal is Decimal(38,18).
Lookup Table
Only integer, Boolean, and string fields support configuring lookup tables.
Click
to enter the Configure Lookup Table dialog box.In the Configure Lookup Table dialog box, configure the relevant parameters.
Configure Lookup Table: By default, it is not configured. You can select Reference Tables to configure the corresponding lookup table for the metric .
Lookup Table Source: Currently only supports Manual Configuration.
Lookup Table Name: Enter the lookup table name. Supports Chinese, English, numbers, and special characters, within 128 characters.
Lookup Table Description: Enter a brief description of the lookup table, within 1000 characters.
Code Information: Supports single input and batch input, up to 500 groups.
Single Input: Click Add Code Value, enter Code Value and Code Name, both must not be empty and must be unique. Additionally, the type of code value needs to match the value type of the metric. You can click
to delete the current row.Batch Input: Click Batch Input, and in the Batch Input Code Information dialog box, batch input code values and code names, each group is separated by a line, and the code value and code name are separated by a half-width colon (:). Click Click To Detect, and the system will automatically parse the code information in the batch input box and fill it into the code information list.
One-click Purge: Click One-click Purge, and the system will automatically purge the information list.
Click Confirm to complete the code value configuration.
NoteWhen batch inputting code information, if there are duplicate code values or code names, after clicking confirm, the system will automatically locate the first error row.
Tag Configuration
Select Tag: Click Select Tag, and you can select tags from the left tag list and reference them in the expression editing area. The tag list supports all tags, project tags, and applied tags. You cannot select the current tag. You can click the Tag Market at the bottom to jump to the tag market to find or apply for more tags.
Click Collapse Tag to collapse the left tag list.
Select Function: Click Select Function, and you can select the required function from the right function list and reference it in the expression editing area. The function list only contains system functions (single-line functions) under the current tenant compute engine and is displayed by classification. You can search by function name. Click the
icon after the function to display detailed information about the function, including function name, function type, command format, and function description. Click the
icon after the function name to copy the current function name.Click Collapse Function to collapse the right function list.
Format: Click Format, and the system will automatically standardize the code content in the current expression editing area.
Syntax Reference Tips:
Arithmetic operation: Supports addition
+, subtraction-, multiplication*, division/, and parentheses()Logical operation: Supports and
&&, or||, not!,in,not inRelational operation: Supports greater than
>, less than<, greater than or equal to>=, less than or equal to<=, equal to==, not equal to!=Conditional expressions only support CASE WHEN. When using CASE WHEN, only content that conforms to the CASE WHEN format is allowed in the editing area.
Supports built-in single-line functions in the engine, such as:
ROUND( @feature.total_liabilities / @feature.total_assets, 2 )
-- Arithmetic operations “ +, -, *, /, () ”-- -- Numeric tags: All arithmetic operators above can be used for arithmetic operations FLOOR( ( @feature.resign_num + @feature.pre_resign_num ) / @feature.total_worker, 2 ) -- Logical operations: and &&, or ||, not !, in, not in -- Relational operations: greater than >, less than <, greater than or equal to >=, less than or equal to <=, equal to ==, not equal to != -- Selection operations: CASE WHEN THE BETWEEN AND ELSE END -- Logical relational operations are generally used for condition judgment -- Overwrite the original selection logic, along with the layered tag logic, and the complex metric calculation logic, but only supports one layer of nesting CASE WHEN condition1 THEN value1 WHEN condition2 THEN value2 WHEN condition3 THEN value3 ELSE default_value END -- Metric layered tags CASE WHEN @feature.salary < 3000 THEN 'Low' WHEN @feature.salary BETWEEN 3000 AND 5000 THEN 'Medium' WHEN @feature.salary > 5000 THEN 'High' ELSE 'Unknown' END -- Complex tax calculation CASE WHEN @feature.salary < 36000 THEN 0 WHEN @feature.salary BETWEEN 36000 AND 100000 THEN @feature.salary×0.05 ELSE @feature.salary×0.1 ENDSyntax Validation: Click Syntax Validation, and the system will automatically validate the existence and validity of the code content in the current expression editing area. The validation rules are as follows:
Existence Validation: Validates whether tags and functions exist. If they do not exist, the system will report an error, and you can check the content based on the error message.
Validity Validation: Validates whether there are invalid characters and whether SQL can be correctly generated. If there are invalid characters or if the tag processing logic parsing fails, the system will report an error, and you can check the content based on the error message.
Click Submit to finalize the creation of the offline tag.
Once the offline tag is created, you must publish it to make it available for use. After publication, project members can utilize the tag for further processing or audience group selection.
In the offline tag list, click the
icon in the operation column to publish the tag.In the Publish Tag dialog box, choose the tag version to publish.
NoteBefore publishing, you can select View Version Comparison to examine the details and differences between versions, ensuring the correct version is published.
Click Confirm to complete the tag's publication process.
What to do next
After the offline tag is created and published, you can list it in the appropriate market for management and use it in further tag development activities. For more information, see Manage Tags.