---
title: "Register a Utility Function"
description: "Register a Global Function so the same Python logic can be reused by alias across objects."
---

<div style="padding: 14px 16px; border: 0.5px solid #AFA9EC; border-radius: 12px; background: #EEEDFE; margin-bottom: 1.5rem;">
  <div style="display: flex; align-items: center; gap: 7px; margin-bottom: 8px;">
    <svg width="16" height="16" viewBox="0 0 16 16" fill="none">
      <path d="M9 2L4 9h4l-1 5 5-7H8l1-5z" stroke="#7f77dd" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round"/>
    </svg>
    <span style="font-size: 11px; font-weight: 500; letter-spacing: 0.05em; text-transform: uppercase; color: #534AB7;">TL;DR</span>
  </div>
  <div style="font-size: 13px; color: #3C3489; line-height: 1.65;">
    A Global Function is a reusable piece of Python (like a <code>weighted_mean</code> helper) that you register once and call by its alias from other objects, instead of copying it into each. Define it once and every object that uses it stays in sync. Write the function body, set an alias, and create.
  </div>
</div>

## What is it?

A **Utility Function / Global Function** is a reusable piece of Python you register once and share across objects, instead of re-writing the same helper each time. In the platform it is called a **Global Function**. Once registered, select it in any object that accepts inputs and call it by its alias.

<div class="flow-diagram">
  <div class="flow-row">
    <div class="flow-box box-global">Global Function<small>weighted_mean</small></div>
    <div class="flow-arrow">→</div>
    <div class="flow-col">
      <div class="flow-box box-de">Data Elements</div>
      <div class="flow-box box-feature">Features</div>
      <div class="flow-box box-report">Reports</div>
      <div class="flow-box box-policy">Policies</div>
    </div>
  </div>
</div>

For example, register `weighted_mean` once and call `weighted_mean(values, weights)` in every Report that needs it, so the calculation lives in one place instead of drifting across copies.

## How to Register

Follow these steps to register a Global Function.

<details open class="step">
<summary>

#### Open the Create Form

</summary>

On the **Resources → Global Functions** page, click **+ New Global Function**.

The form opens with an editable name field at the top left (**New Global Function**). Type a descriptive name (for example, `Weighted Mean`) and confirm to land on the full form.

</details>

<details open class="step">
<summary>

#### Set the Output Type and Alias

</summary>

Set the **Output Type** (optional) - the type of value the function returns (for example, `Numerical`, `String`, `Boolean`).

Set the **Alias** <span style="color: #E5484D;">\*</span> - the name used to call the function in code (for example, `weighted_mean`).

</details>

<details open class="step">
<summary>

#### Define Arguments and Inputs

</summary>

Click **Add Arguments** to define what your function takes in as input (for example, `values` and `weights`). Each argument becomes a variable you can use in the Definition.

Under **Input**, select any other Global Functions this one relies on, so you can call them by their alias inside the definition (for example, a `roc_auc` Global Function reused by another function like `gini`):

```python
# Global Function: gini  (alias: gini)
# Input: roc_auc  <- another Global Function, selected here so it can be called by its alias below
return 2 * roc_auc(scores, labels) - 1
```

</details>

<details open class="step">
<summary>

#### Write the Logic

</summary>

In the **Definition** editor, write the function body in Python. The arguments you defined are already in scope, so use them directly. Whatever the function returns is what callers receive when they call it by its alias. You can import standard libraries (`numpy`, `math`, `datetime`, etc.).

Write the logic directly, not wrapped in a `def`. The platform builds the function signature from the **Alias** and **Arguments** you set.

For example, the `weighted_mean` Global Function, using the `values` and `weights` arguments:

```python
"""Return the weighted mean of values, or None if the weights sum to zero."""
total = sum(weights)
if not total:
    return None
return sum(v * w for v, w in zip(values, weights)) / total
```

</details>

<details open class="step">
<summary>

#### Fill in Properties and Create

</summary>

Fill in the [Properties](/user-guide/how-tos/common-registration-info/#properties) (Description and Group), then click **Create** at the bottom right. The Global Function is saved as a draft and you land on its details page.

</details>

## What's Next

To use a Global Function, select it in the **Input** or **Resources** section of any object that supports it, then call it by its alias in that object's definition. It appears in code autocomplete inside the editor.

Next steps:

- Use the function inside a [Data Aggregate](/user-guide/how-tos/register-a-data-aggregate/), [Feature](/user-guide/how-tos/register-a-feature/), or [Report](/user-guide/how-tos/register-reports/).
- Send it for [approval](/user-guide/how-tos/approve-an-object/) so it can be used outside your draft workspace.
