> 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/advocate-program/manage-advocate-participants/custom-and-calculated-fields/calculated-fields-explained.md).

# 计算字段说明

**受限**: 计算型自定义字段仅适用于某些产品版本。 [联系支持](https://app.impact.com/support/portal.ihtml?createTicket=true&) 以升级您的倡导者计划并获得访问权限。

通过 [自定义字段](/brand/zh/what-would-you-like-to-learn-about/advocate-program/manage-advocate-participants/custom-and-calculated-fields/custom-fields-for-advocate-explained.md)，您可以向 impact.com 发送关于您的 Advocate 参与者的各种额外信息，超出运行推荐计划所需的基本信息。

计算字段接收用户和事件数据，其值会被计算、存储，并显示在参与者的个人资料中。设置好计算字段后，当您发送符合条件的 Advocate 计划事件时，其值会动态更新。

{% hint style="info" %}
**示例：** 可将计算字段配置为统计参与者在一个月时间窗口内进行至少 100 美元购买的次数。然后，您可以设置您的计划，向每月进行至少 3 次此类 100 美元购买的参与者发放特别奖励。
{% endhint %}

#### 默认计算字段

默认情况下，系统会为您提供四个计算字段。您一开始设置计划规则时就可以引用它们。

<details>

<summary>默认计算字段</summary>

| 计算字段               | 说明                                |
| ------------------ | --------------------------------- |
| lastSeenDate       | 跟踪用户在 Advocate 中最后一次被 upsert 的时间。 |
| firstPurchaseDate  | 跟踪我们收到该参与者购买事件的第一个日期。             |
| lastPurchaseDate   | 跟踪该参与者最近一次购买事件的日期。                |
| totalPurchaseCount | 跟踪该参与者购买事件的总数。                    |

</details>

#### 客户端创建的计算字段

您可以创建超出所提供默认字段之外的自定义计算字段。设置计算字段时，您可以：

* 如果您希望计算仅在有限时间内运行（例如 1 月 1 日至 2 月 17 日），可以添加开始和结束日期。这一设定的时间范围称为活动期。
* 指定一个重复的 [跟踪窗口](/brand/zh/what-would-you-like-to-learn-about/advocate-program/manage-advocate-participants/custom-and-calculated-fields/tracking-windows-for-calculated-fields-explained.md) 用于您的求和和计数计算。跟踪窗口可以是固定窗口（例如单个日历月或年），也可以是滑动窗口（例如最近 90 天）。
* 通过添加筛选器或编写 JSONata 表达式，为执行计算的时间设置额外约束。本文中会更详细地讨论这些选项 [设置计算字段](/brand/zh/what-would-you-like-to-learn-about/advocate-program/manage-advocate-participants/custom-and-calculated-fields/set-up-a-calculated-field.md).

{% hint style="info" %}
**注意：** 如果您的计算字段具有活动期或跟踪窗口，那么在计算周期结束后，其值将不会更新。如果您的计算字段具有活动期（或仅针对求和/计数计算的跟踪窗口），那么在计算周期结束后，其值将不再进一步更新。不过，这些值仍会显示在每位参与者的个人资料中。
{% endhint %}

<details>

<summary>客户端创建的计算字段</summary>

构建计算字段时，您可以使用多种计算类型。

| 计算       | 说明                                                | 示例                                                  |
| -------- | ------------------------------------------------- | --------------------------------------------------- |
| 求和       | 计算以下内容的总和： `{fieldname}` 字段来自 `{eventkey}` 事件     | 汇总推荐好友在注册后前 30 天内的所有购买金额。根据消费金额向客户 Advocate 发放分级奖励。 |
| 数量       | 统计以下内容的数量： `{eventkey}` 事件                        | 当参与者已完成超过 10 次购买时奖励他们。                              |
| 首次出现（日期） | 计算第一次的时间戳 `{eventkey}` 事件                         | 如果参与者在某个日期之前开始购买，则奖励他们。                             |
| 最后出现（日期） | 计算最后一次的时间戳 `{eventkey}` 事件                        | 如果参与者的上一次购买发生在 5 天内，则奖励他们。                          |
| 首个值      | 计算以下内容的值： `{fieldname}` 来自首次 {eventkey} 事件的字段     | 当参与者首次进行大额购买时奖励他们。                                  |
| 最后值      | 计算以下内容的值： `{fieldname}` 来自最近一次的字段 `{eventkey}` 事件 | 当参与者的最后一笔付款达到某个最低值时奖励他们。                            |

</details>


---

# 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/advocate-program/manage-advocate-participants/custom-and-calculated-fields/calculated-fields-explained.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.
