For the complete documentation index, see llms.txt. This page is also available as Markdown.

Computed fields

Turn behavioural and profile data into aggregated values available as ordinary schema fields.

Your goal

Get an aggregate - sales over the last 90 days, favourite category, an RFM score - available as a normal field on the UserPoint, so queries, segments, and dashboards can use it without recomputing anything.

Expected outcome

A field declared in your schema whose value is calculated on a schedule, queryable exactly like a collected field.

What a computed field is

A computed field is a dynamic field defined in the schema, linked to a script that is triggered for each new user activity or profile update and that performs a computation of a function's result on a regular basis.

A Computed Field Function is the plugin behind it - of type COMPUTED_FIELD_FUNCTION. The computed field itself is an instance of that function applied in a specific context, and it must be declared in your schema to be usable.

Computed fields are always defined at the UserPoint level.

The elements that define one

Element
What it is

Input data

One or more sources: activity data, profile data, or both.

Formula

The logic - a sum, a count, or a more complex operation.

Lookback window

The historical depth to analyse.

Update frequency

How often the result is recomputed - typically daily, weekly, or monthly.

Worked definitions

Sales generated on smartphones over the last 3 months

  • Input data: purchase data filtered on "smartphone" products

  • Formula: sum of the sales figures for each sale

  • Lookback window: 90 days

  • Update frequency: daily

Favourite type of content

  • Input data: page views

  • Formula: sum of page views per category - the category field to use has to be defined - and the category with the highest score is saved as the favourite

  • Lookback window: 12 months

  • Update frequency: monthly

The moving parts inside one

Part
What it holds

State

The data stored to build the result - the history. Each new activity updates the state, which is why the state is closely tied to the lookback window.

Logic

Simple, like a formula, a sum, or a count; or more complex, like a logical operation.

Result

The data calculated and stored - the score or scores you use. A single variable or an object, depending on the computation. It is computed from the state.

When to use one, and when not to

Use one when the outcome cannot be achieved with existing schema directives, or to simplify a query by replacing several directives with a single field. Because the value is precomputed, queries using it are faster.

Handled well by computed fields:

  • Retrieve the most recent event - last visit, last transaction.

  • Get the total amount for a type of event - sum of transactions in the last 30 days, total spend on a product category.

  • A weighted sum, such as an affinity total.

  • Compare several channels, for instance to find the best channel for transactions.

Common business uses: developing customer understanding (whether someone buys online, offline, or both), making segmentation easier (an RFM score), optimising personalisation (appetite for discounts), and enhancing measurement (sales over the past 30 days, to measure a campaign's impact).

A standard directive is enough when you only need to filter, for example: get all users with at least a specific amount for one category.

Adding a computed field for something a directive already does adds a moving part for no gain.

Identifying the top X% of a group - the top 10% of buyers, say - is not something a computed field can do.

Computed fields are designed to compute data at the level of a single user. Comparing one user's result against the rest of the datamart requires specific development, and feasibility can only be assessed case by case.

What it changes in your queries

The same use case - users who spent more than €100 on IT products in the last three months - expressed both ways:

The sum is computed while the query runs.

The field is calculated on a regular basis, so no computation happens during query execution. Response times are faster because the value is precomputed and readily available.

Once live, a computed field behaves like a regular field - it is transparent to the person querying it.

Lifecycle

  1. INITIAL - the instance is created with this status.

  2. INITIAL_LOADING - once declared in the schema and successfully validated, an initial loading job is triggered.

  3. ACTIVE - the computed field becomes active if the job completes successfully.

Technically: the field is declared in the schema, the state is updated by new user activities or profile updates, the result is computed from the current state, and the result is stored for querying.

Set one up

Computed fields are created as plugins, which requires collaboration with the mediarithmics Professional Services team: defining the logic, writing the plugin specification, developing the plugin, and configuring the computed field. Users are not autonomous in creating them today - discuss your needs with your Account Manager.

The project runs in these stages: framing (which fields to calculate, the methodology, the update frequency), writing the plugin specification, developing the plugin, and configuring the computed fields including schema indexing and production testing.

1

Create the Computed Field Function

A plugin of type COMPUTED_FIELD_FUNCTION, created through the API following the standard plugin process, or through Computing Console. See Build a computed field.

2

Create the computed field in the platform

In Navigator > Settings > Datamart, open Computed Fields and add a new one. Select the plugin and the version of the instance to use, then complete:

Field
What it sets

Name

The name of the computed field.

Description

Optional.

Technical name

The name used to reference the field in the schema.

Compute period (in days)

The maximum duration before the periodic update of the result.

Events filter

A GraphQL selector query filtering the activities that trigger state updates.

3

Declare it in your schema

Use the @ComputedField directive at the right level, with a technical name matching the one used at creation:

Saving triggers a schema validation, which checks that your datamart has access to every declared computed field and verifies their integration with the schema.

4

Wait for the initial loading

Once the schema is validated, a job initialises the field so that its state matches the current timeline. For every UserPoint in the datamart, the timeline is processed and the update functions are executed.

Monitor it in Computing Console > Computed Fields, where you can see whether the field is ready or still loading.

This can take up to 72 hours, because it computes the timelines of all UserPoints.

5

Use it

Like any other field:

And if it is indexed:

Boundaries

Question
Answer

Can it be computed per profile rather than per UserPoint?

Yes - for each computed field you choose whether it is computed at the UserPoint mesh (possibly with several linked profiles) or at the profile mesh.

Can it live anywhere in the schema?

No. A computed field is always defined at the root of the schema, on the UserPoint.

Can one computed field feed another?

Not in the Alpha version, because the order in which computed fields are calculated cannot be controlled.

Can it use statistics over the whole datamart?

Not by design - computed fields compute data at a single-user level. A comparison against the rest of the datamart may sometimes be possible through specific development, assessed case by case.

Can I create one myself?

Not currently. The Professional Services team is involved in the project.

Verify

  • The field appears in the schema and validation passes.

  • Computing Console > Computed Fields reports the initial loading as finished.

  • SELECT { your_field } FROM UserPoint returns values.

  • If the field is indexed, a WHERE query on it returns a plausible population.

Last updated

Was this helpful?