# 自定义维度

## 概述

在 Recurve 中，自定义维度允许用户在语义模型中定义新的维度字段。通过自定义维度，用户可以增强数据分析能力，实现更多的数据分组、筛选和细分分析。

## 什么是自定义维度？

自定义维度是用户根据计算逻辑、数据转换或预设条件自行定义的分类字段。这些维度可以在不修改原始数据集的情况下，帮助优化和细化分析结果。

## 应用场景

自定义维度通常用于以下场景：

* **派生分类：**&#x521B;建新的分类方式，例如根据年龄字段分组为“青年”、“中年”和“老年”。
* **条件标签：**&#x57FA;于业务规则为数据打标签，例如将消费金额超过某个阈值的客户标记为“高价值客户”。
* **合并属性：**&#x5C06;多个字段组合为一个维度，例如将“地区”和“销售区域”合并为一个字段。
* **数据标准化：**&#x5BF9;不同数据集的值进行统一和标准化处理，确保数据一致性。

## 创建自定义维度

要创建自定义维度，请按照以下步骤操作：

{% hint style="info" %}
确保 Cube 已设置主键，才能继续创建自定义维度。参考文档 [语义层模型 (Cube)](/cn-reorc-help-center/semantics_modeling/yu-yi-ceng-mo-xing-cube.md#chuang-jian-cube)
{% endhint %}

1. 点击 **+** 按钮，选择 **添加维度（Add a dimension）**。

<figure><img src="/files/ara7inj585FngvFenuxf" alt="" width="375"><figcaption></figcaption></figure>

2. 在弹出的窗口中填写详细信息：
   1. **字段标签（Field label）** 会根据 **字段名称（Field name）** 自动生成。
   2. 输入自定义公式时，可以点击右侧字段列表，自动将字段添加到公式输入框中。

<figure><img src="/files/ox50l9dGEHxHMBspxVJs" alt=""><figcaption><p>将 product_id 和 product_name 拼接（使用 PostgreSQL 语法）</p></figcaption></figure>

3. 点击 **校验** 按钮，检验公式是否正确。

{% hint style="warning" %}
需确保自定义公式的语法符合数据库类型的语法。
{% endhint %}

4. 验证无误后，点击 **添加** 按钮，将自定义维度添加到当前语义模型中。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.reorc.com/cn-reorc-help-center/semantics_modeling/yu-yi-ceng-mo-xing-cube/zi-ding-yi-wei-du.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
