> For the complete documentation index, see [llms.txt](https://help.impact.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.impact.com/brand/zh/what-would-you-like-to-learn-about/platform-features/multi-program-reports/data-lab-custom-reports/create-custom-measures-in-data-lab.md).

# 在 Data Lab 中创建自定义指标

Data Lab 的内置指标可以满足大多数报告需求，但有时您需要针对自己的项目进行特定计算，例如自定义转化率、加权总计，或两个现有指标之间的比率。自定义指标可让您使用现有指标和维度定义自己的公式，因此计算结果会像任何标准指标一样显示在可视化中。

{% hint style="warning" %}
**重要提示：** 我们 *强烈* 建议您在开始阅读本文前，先参考 [Data Lab 简介](https://help.impact.com/brand/zh/what-would-you-like-to-learn-about/platform-features/multi-program-reports/data-lab-custom-reports/data-lab-introduction.md) 。
{% endhint %}

1. 在左侧导航菜单中，选择 ![](https://1186853034-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwMLlMoFBtKJa8ptd3zaw%2Fuploads%2Fgit-blob-230534471fef5f40808e921e41ee44e4a06ded03%2Fe6cb9548999afdc1ed3ce4942e4cb5b45b5cecbd323267aac2a7cd1915fccc09.svg?alt=media) **\[Engage] → 报告** → [**数据实验室**](https://app.impact.com/secure/advertiser/engage/reportBuilder.ihtml).
2. 选择一个 **可视化** 以开始。
3. 在右侧工具栏的 *维度和度量* 部分中，选择 ![](https://1186853034-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwMLlMoFBtKJa8ptd3zaw%2Fuploads%2Fgit-blob-6282f271b7521383385339243690b303086736d9%2F3b5a585dd2895bdf1c30d1236c72ba590dddd18717863b27074c8d313d05ae20.svg?alt=media) **\[创建自定义度量]**.

   <div data-with-frame="true"><figure><img src="https://1186853034-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwMLlMoFBtKJa8ptd3zaw%2Fuploads%2FaJ9k8ckxQGr9Bokgj8Mb%2FUntitled%20design%20(12).png?alt=media&amp;token=68dfc0f3-adb5-4c88-8447-6ceafc61b73d" alt="" width="355"><figcaption></figcaption></figure></div>
4. 在 *公式* 字段中，输入自定义度量的计算公式。如果只需要单个维度值的结果（例如，一种事件类型），可以在公式中使用  `Filter` 。

   * 有关详细信息，请参阅下文的 [将度量筛选至特定值](#filter-a-measure-to-a-specific-value) 。

   <div data-gb-custom-block data-tag="hint" data-style="info" class="hint hint-info"><p><strong>示例：</strong> “ <em>转化率</em> ”度量使用 <code>Actions / Clicks</code>。impact.com 会在 <em>公式</em> 框下方显示验证消息，以指明公式是否有效。</p></div>
5. 为自定义指标命名（例如， *转化率）*.
6. 在 ![](https://1186853034-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwMLlMoFBtKJa8ptd3zaw%2Fuploads%2Fgit-blob-c2cb550b55c51ea1eeff0acbd6f437a03b621a2c%2F60d033ae8a04c14498d5229c3c0160ac05feea7f605dbd770741793c900469f0.svg?alt=media) **\[下拉菜单]**&#x4E2D;选择指标的 **格式**。您可以选择 *数字*, *字符串*, *百分比*或 *货币*.
7. 选择 **保存** 以保存您的自定义度量。

   <div data-with-frame="true"><figure><img src="https://1186853034-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwMLlMoFBtKJa8ptd3zaw%2Fuploads%2FeRSxwBeihOE4jt2Um20f%2FScreenshot%202026-04-27%20at%2017.31.58.png?alt=media&amp;token=805ccf5a-b8b8-499d-86e7-efc04994dc80" alt="" width="563"><figcaption></figcaption></figure></div>

## 将度量筛选为特定值

自定义指标通常会跨某个维度的所有值进行计算。有时，您只想查看某个值的结果，例如单个事件类型的转化率，而不必单独创建可视化图表或依赖数据透视表。此时可以使用 `Filter` 函数，直接在公式中将指标限定为某个维度值。

1. 在右侧工具栏的「维度和指标」部分，选择 ![](https://1186853034-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwMLlMoFBtKJa8ptd3zaw%2Fuploads%2Fgit-blob-6282f271b7521383385339243690b303086736d9%2F3b5a585dd2895bdf1c30d1236c72ba590dddd18717863b27074c8d313d05ae20.svg?alt=media) **\[创建自定义度量]**.
2. 输入 `Filter` 到 *公式* 字段中。输入时，Data Lab 会建议可用的指标、维度和值。系统会显示 *有效* 或 *无效* 标签，指示公式是否有效。
3. 为指标输入 **名称** （例如， *销售转化率*).
4. 在 ![](https://1186853034-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwMLlMoFBtKJa8ptd3zaw%2Fuploads%2Fgit-blob-c2cb550b55c51ea1eeff0acbd6f437a03b621a2c%2F60d033ae8a04c14498d5229c3c0160ac05feea7f605dbd770741793c900469f0.svg?alt=media) **\[下拉菜单]**&#x4E2D;选择指标的 **格式**.
5. 选择 **保存**.

<div data-with-frame="true"><figure><img src="https://1186853034-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwMLlMoFBtKJa8ptd3zaw%2Fuploads%2FAPIC59sIvphC3MM0Mmdz%2FScreenshot%202026-08-26%20at%2014.56.52.png?alt=media&amp;token=573db799-5c8e-4641-abe9-eef93c3bb01a" alt="" width="485"><figcaption></figcaption></figure></div>

### Filter 函数格式

使用以下格式的 Filter 函数： *Filter(Measure, Dimension=Value)。*

<table><thead><tr><th width="167.26953125">元素</th><th>需要输入的内容</th></tr></thead><tbody><tr><td>衡量方式</td><td>现有指标，例如 <em>Actions。</em></td></tr><tr><td>维度</td><td>用于限定范围的维度，例如 <em>事件类型</em>.</td></tr><tr><td>=</td><td>唯一支持的比较运算符是 <code>Filter</code> 不支持使用 <code>!=</code>, <code>></code>, <code>&#x3C;</code>, <code>IN</code>, <code>AND</code>或 <code>OR</code>.</td></tr><tr><td>值</td><td>该维度的一个值，例如事件类型的名称。</td></tr></tbody></table>

### 组合筛选条件

* **将筛选条件与其他指标组合：** 使用 `+`, `-`, `*`, `/` 和括号。不能在一个筛选条件中嵌套另一个筛选条件，例如 `Filter(Filter(...))`.
* **统计多个值：** 为每个值单独添加一个 Filter 公式。\
  例如： `Filter(Actions, Event Type=Sale) + Filter(Actions, Event Type=Lead)`
* **没有匹配的行：** 该指标会显示 **0**；如果格式设为 **0%** ，则会显示 *百分比*.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://help.impact.com/brand/zh/what-would-you-like-to-learn-about/platform-features/multi-program-reports/data-lab-custom-reports/create-custom-measures-in-data-lab.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
