> 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 天内完成的所有购买。根据消费金额向客户倡导者发放分级奖励。 |
| 数量       | 统计以下项的数量： `{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:

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

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.
