# 自定义指标

## 概述

在 Recurve 中，自定义指标允许用户在语义模型中创建新的数值型计算，定义关键业务指标。

## 什么是自定义指标？

自定义指标是用户基于现有字段，通过聚合、数学运算或条件逻辑定义的度量值。\
这些指标可以帮助用户深化洞察，提升数据分析的灵活性。

## 应用场景

* **新增业务指标：**&#x5B9A;义关键绩效指标（KPI），例如通过公式 `（收入 - 成本）/ 收入` 计算“利润率（Profit Margin）”。
* **条件聚合：**&#x521B;建条件指标，例如筛选单笔交易金额高于某个值的“高价值订单（High-Value Orders）”。
* **比率与百分比计算：**&#x8BA1;算转化率（Conversion Rate），例如通过公式 `(总销售量 / 总访客数) * 100`。
* **自定义加权：**&#x6309;照业务规则对不同数值赋予不同权重，进行灵活计算。

## 创建自定义指标

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

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

1. 点击 **+** 按钮，选择 **添加指标（Add a measure）**。

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

2. 在弹出的窗口中填写相关信息：
   1. **字段标签（Field label）** 会根据 **字段名称（Field name）** 自动填充。
   2. 输入自定义公式时，可以点击字段列表，自动将字段添加至公式输入框中。
   3. 有关聚合方式和示例用法，参考文档： [聚合计算函数](/cn-reorc-help-center/semantics_modeling/yu-yi-ceng-mo-xing-cube/zi-ding-yi-zhi-biao/ju-he-ji-suan-han-shu.md)

<figure><img src="/files/pAA4FVEoTl2ohf5Svv4O" alt=""><figcaption></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-zhi-biao.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.
