--- title: "Register a Utility Function" description: "Register a Global Function so the same Python logic can be reused by alias across objects." ---
TL;DR
A Global Function is a reusable piece of Python (like a weighted_mean 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.
## 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.
Global Functionweighted_mean
→
Data Elements
Features
Reports
Policies
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.
#### Open the Create Form 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.
#### Set the Output Type and Alias Set the **Output Type** (optional) - the type of value the function returns (for example, `Numerical`, `String`, `Boolean`). Set the **Alias** \* - the name used to call the function in code (for example, `weighted_mean`).
#### Define Arguments and Inputs 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 ```
#### Write the Logic 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 ```
#### Fill in Properties and Create 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.
## 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.