> ## Documentation Index
> Fetch the complete documentation index at: https://moengage-docs-limits-messaging.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a Computed Trait

> Step-by-step guide to creating computed traits in MoEngage using count, aggregation, first/last value, or SQL computation methods.

<Note>
  This is an Early Access feature. To enable it for your account, please contact your MoEngage Customer Success Manager (CSM) or the Support team.
</Note>

This article guides you through creating a new computed trait, managing existing computations, and using them to enhance your campaigns.

# Create

To get started, perform the following steps:

1. From the left navigation menu in the MoEngage dashboard, navigate to **Data** > **Computed Traits**.
2. Click **+ Create New Computation**. The **Create computation** dialog box appears. <img alt="2025-08-18_18-24-47.png" src="https://mintcdn.com/moengage-docs-limits-messaging/OEp1ZQWSlr2NOm-a/images/moengage_56b1cf.png?fit=max&auto=format&n=OEp1ZQWSlr2NOm-a&q=85&s=29cc63124199d0c09909036b7baf16cd" width="3156" height="936" data-path="images/moengage_56b1cf.png" />
3. Click the desired computation method. You have the following options:
   * **Count**
   * **Aggregation**
   * **First/Last Value**
   * **SQL Computation**

For more information on methods of computation and their use cases, refer to [Computed Traits - Overview](/user-guide/data/computed-traits/computed-traits-overview).

The process includes three steps:

* [Step 1: Basic Details](/user-guide/data/computed-traits/create-a-computed-trait#step-1-basic-details)
* [Step 2: Define Computed Trait](/user-guide/data/computed-traits/create-a-computed-trait#step-2-define-computed-trait)
* [Step 3: Scheduling](/user-guide/data/computed-traits/create-a-computed-trait#step-3-scheduling)

## Step 1: Basic Details

First, define the basic details and specify which users the computation applies to.

1. **Computed trait name:** Enter a unique name for your computation. This name will appear as a new user attribute across the MoEngage UI (for example, "Lifetime Value").
2. **Description:** Briefly explain what the computation calculates for your team's reference.
   <img src="https://mintcdn.com/moengage-docs-limits-messaging/e22o1m7gKjbDolNa/images/moengage_8e0916.png?fit=max&auto=format&n=e22o1m7gKjbDolNa&q=85&s=5186464c1ca8ec98ad234cd02213e5ee" alt="Screenshot 2025-08-18 at 6.42.23 PM.png" width="3202" height="818" data-path="images/moengage_8e0916.png" />
3. **Filter users:** Choose the users to be part of the computation. You can select:
   * **All users:** The computation will run for every user in your account.
   * **Filter users by:** Define a specific segment of users based on user properties, events, or affinities. For more information, refer to [Create Segments](/user-guide/segment/segment-operations/rule-based-filter-segments).
     <img src="https://mintcdn.com/moengage-docs-limits-messaging/vM8uYc_j6-JIKfxn/images/moengage_b98705.png?fit=max&auto=format&n=vM8uYc_j6-JIKfxn&q=85&s=1b1b2d49f9b2ed88532b261b7e4758f3" alt="Screenshot 2025-08-18 at 6.43.07 PM.png" width="3188" height="558" data-path="images/moengage_b98705.png" />

## Step 2: Define Computed Trait

Next, define the logic for how your trait will be calculated.

1. **Select the Type:** In the **Type** section, choose the desired type of computation. You can create traits based on:
   <img src="https://mintcdn.com/moengage-docs-limits-messaging/nKOco8ydI6v-QQf4/images/moengage_11c9ad.png?fit=max&auto=format&n=nKOco8ydI6v-QQf4&q=85&s=b4fabf814ace2dc1fee6ed887ad4805f" alt="Screenshot 2025-08-19 at 1.40.36 PM.png" width="3174" height="366" data-path="images/moengage_11c9ad.png" />
   * **Count:** Count the number of times users performed an action.
   * **Aggregation:** Aggregate values of an event attribute (for example, Total order value).
   * **First/Last Value:** Identify the first or last value of an event attribute.
   * **SQL Computation:** Write a custom SQL query for complex calculations.
2. **Set up the Configuration:** In the **Configuration** section, based on the type of computation that you selected, do the following:
   * For a **Count** computation, select the event to count, define the time period, and optionally add attribute filters.
     <img src="https://mintcdn.com/moengage-docs-limits-messaging/d-9sdB9j1_Pt9rjU/images/moengage_a063c5.png?fit=max&auto=format&n=d-9sdB9j1_Pt9rjU&q=85&s=a16d21f96810296e7fdb93c4f338fee2" alt="Screenshot 2025-08-19 at 1.41.45 PM.png" width="3162" height="676" data-path="images/moengage_a063c5.png" />
   * For an **Aggregation** computation, select the event and the time period. Then, choose the aggregation function. The following functions are available: **Sum**, Min, Max, Average, Median, Distinct count, and **True if event exists**. After selecting the function, select the event attribute you want to compute.
     <img src="https://mintcdn.com/moengage-docs-limits-messaging/dSNSCF0_bHFH9IAW/images/moengage_150954.png?fit=max&auto=format&n=dSNSCF0_bHFH9IAW&q=85&s=eb5bbe61b88207edd7d9835480ffac84" alt="Screenshot 2025-08-19 at 1.49.48 PM.png" width="3184" height="772" data-path="images/moengage_150954.png" />
   * For a **First/Last Value** computation, select the event and time period. Then, choose whether to compute the **First value** or **Last value** of a specific event attribute.
     <img src="https://mintcdn.com/moengage-docs-limits-messaging/haZKi6WfMK0B1Yv7/images/moengage_c43fea.png?fit=max&auto=format&n=haZKi6WfMK0B1Yv7&q=85&s=f13116b5eb8e3c20b38da94e35835917" alt="Screenshot 2025-08-19 at 1.51.54 PM.png" width="3174" height="768" data-path="images/moengage_c43fea.png" />
   * For a **SQL Computation**, in the SQL editor, write your query. You can use the left section to browse and select user and event tables. Your query must return two columns: the MoEngage ID and the computed value for your new trait.
     <img src="https://mintcdn.com/moengage-docs-limits-messaging/XnyI-PPqrWnkfeUW/images/moengage_ee8734.png?fit=max&auto=format&n=XnyI-PPqrWnkfeUW&q=85&s=9fdf9029e32eb4ea6249967c3b1bcfa6" alt="Screenshot 2025-08-19 at 2.12.22 PM.png" width="3168" height="1560" data-path="images/moengage_ee8734.png" />
3. **Define the Data type:** Choose the data type of the computed trait's output (for example, **Numerical**, **String**, **Boolean**). Defining a data type is only permitted when you select **SQL** as the computation type. For other computation types, the data type is auto-populated.
4. **Review the Summary:** A plain-language summary of your configuration will be displayed for confirmation.
   <img src="https://mintcdn.com/moengage-docs-limits-messaging/OEp1ZQWSlr2NOm-a/images/moengage_561d4b.png?fit=max&auto=format&n=OEp1ZQWSlr2NOm-a&q=85&s=6c43ae81cb222e626893dd0c8cac4f0e" alt="Screenshot 2025-08-19 at 1.56.12 PM.png" width="3152" height="114" data-path="images/moengage_561d4b.png" />
5. **Preview the trait:** Before navigating to the next step, you must test the logic. Perform these steps to preview:
   1. In the **Preview Computed Trait** section, select a preview type.
      * **A specific user**: Test the configuration on a specific user ID.
      * **A set of 10 random users**: Test the configuration on a set of ten random users.
   2. Click **Preview**. A table is generated with ID and computed value.
      <img src="https://mintcdn.com/moengage-docs-limits-messaging/3w5OCJFVVxEvR6nM/images/moengage_70d77b.png?fit=max&auto=format&n=3w5OCJFVVxEvR6nM&q=85&s=dc7a97de6e0427d97882646b73df4396" alt="Screenshot 2025-08-19 at 2.06.47 PM.png" width="3168" height="1150" data-path="images/moengage_70d77b.png" />
      You can export this preview. To do so, click **Download**.

## Step 3: Scheduling

Finally, decide how and when your computation should run. Perform the following steps to schedule and publish your computed trait.

1. In the **Schedule section**, select when the computation will execute.

   * In the **One-time** section, select **Run at next schedule** to run the computation once at the next scheduled time.\
     or
   * In the **Periodic section**, select the computation to run repeatedly on a **Weekly** or **Monthly** basis to keep the user attribute updated. You can adjust the schedule from the **Settings** page.
     <img src="https://mintcdn.com/moengage-docs-limits-messaging/9bRELs2_693LjjTx/images/moengage_65daee.png?fit=max&auto=format&n=9bRELs2_693LjjTx&q=85&s=5c8fe01320b8eeaf5fc01a6a1ba9d4f7" alt="Screenshot 2025-08-19 at 2.34.25 PM.png" width="3170" height="416" data-path="images/moengage_65daee.png" />

   <Note>
     Computations can also be scheduled to run at a **daily** frequency. To enable daily scheduling for your account, contact your account manager.
   </Note>
2. For **Periodic** computations, choose how to handle existing values for users. Select one of the following in the **Computation action**:
   <img src="https://mintcdn.com/moengage-docs-limits-messaging/gTh4voXJUMP5WVJC/images/moengage_99c2b2.png?fit=max&auto=format&n=gTh4voXJUMP5WVJC&q=85&s=51aa88965829498edb1bf2166c8fb0a4" alt="Screenshot 2025-08-19 at 2.35.10 PM.png" width="3162" height="772" data-path="images/moengage_99c2b2.png" />
   * **Replace:** Overwrites the old value with the new one for users who meet the computation definition. If a user no longer meets the definition, their existing value is retained.
   * **Compute only for new users:** Calculates the value only for users who do not already have a value for this trait.
   * **Add to existing value:** Adds the newly computed value to the user's current value.
   * **Subtract from existing value:** Subtracts the newly computed value from the user's current value.

Once you are done, click **Publish** to create your computed trait.

# Manage Your Computations

The Computed Traits page lists all the computations you have created.

### Navigation

1. After creating the computed trait, navigate to **Data** > **Computed Traits**. The Computed traits page appears.
   <img src="https://mintcdn.com/moengage-docs-limits-messaging/i-gTHbDU7cpgLIG6/images/moengage_1bf515.png?fit=max&auto=format&n=i-gTHbDU7cpgLIG6&q=85&s=99f19252bb7215921865e2a565d444f1" alt="Screenshot 2025-08-19 at 2.53.33 PM.png" width="3134" height="1560" data-path="images/moengage_1bf515.png" />
   On this page, you can:
   * Use the search box to search for a computed trait.
   * See information like **Type**, **Schedule**, and **Status**.
   * Use the filters in the header to filter the created computed traits by type, schedule, or status.
2. For a computed trait, you can edit, pause, or view the computation. To do so, click the ellipsis icon against a name and select the desired option.
   <img src="https://mintcdn.com/moengage-docs-limits-messaging/nKOco8ydI6v-QQf4/images/moengage_0ea0bf.png?fit=max&auto=format&n=nKOco8ydI6v-QQf4&q=85&s=013118b3eaa44225ad4b402f97fa2b79" alt="Screenshot 2025-08-19 at 3.02.47 PM.png" width="3054" height="280" data-path="images/moengage_0ea0bf.png" />

* * **View:** See the detailed configuration of a computation on a new page. Alternatively, you can access the detail page by clicking the trait name.
    <img src="https://mintcdn.com/moengage-docs-limits-messaging/e22o1m7gKjbDolNa/images/moengage_9084e4.png?fit=max&auto=format&n=e22o1m7gKjbDolNa&q=85&s=7afd22e3701855d51898baa0f7cae58c" alt="Screenshot 2025-08-19 at 3.20.05 PM.png" width="3154" height="1132" data-path="images/moengage_9084e4.png" />
    The detail page contains the following information:
    * **Basic details**: This section contains information on when the computed trait was created, the scheduled details, last run and next run timestamps, and the filtered users' details.
    * **Computation type**: This section contains information about the type of computation and its configuration.
    * **Run history**: This section provides a detailed view of the computation history.
  * **Pause/Resume**: Pause the computation, or resume a paused computation.
  * **Edit:** Modify a computation. You can only make changes before its first scheduled run. After the first run, only the schedule can be changed.

<Info>
  - You can have a maximum of ten active computations at any given time. This includes computations with Scheduled, Processing, or Active statuses.
  - Computed trait values are applied to user attributes at a processing speed of up to 1 million users per hour.
</Info>

# Use Your Computed Traits

Once your computation has run successfully, the new trait will be available as a standard user attribute throughout MoEngage.

* **In Segmentation:** In the segment creator, go to **User Property**, find your new computed trait by name, and use it to build your segment.
* **In campaign personalization:** Use Jinja to insert the trait's value directly into your messages. For example: `Hi {{UserAttribute['First Name']}}, you have {{UserAttribute['Loyalty Points']}} points!`. Alternatively, use @ to add the attribute to your content.
* **In Flows:** Use the computed trait as a condition to guide users down different paths in a flow.
