> 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 中最后一次被 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 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.
