> 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&) 以升级您的 Advocate 计划并获得访问权限。

通过 [自定义字段](/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 中最后一次被更新写入的时间。 |
| 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 dynamically by asking a question.

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

```
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=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
