> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://help.sigmacomputing.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://help.sigmacomputing.com/_mcp/server.

# Create reusable custom functions

You can define custom functions to represent frequently used complex calculations that combine logic, aggregates, and other type of operations. There are many advantages to adding custom functions to your Sigma practice:

* Use custom functions to encode business logic instead of repeating it.
* Encapsulate complex calculations that are common business use cases, for easier use.
* Expose your proprietary warehouse functions, making them consumable.

## Requirements

To create and manage custom functions, you must be assigned the Admin [account type](/docs/account-type-and-license-overview).

Users with access to write formulas can use custom functions in the same manner as built-in Sigma functions.

## Limitations

* You can use custom functions inside workbooks and metrics.
* All arguments of the custom function are required; there are no optional arguments.
* User-defined functions (UDFs) from your data warehouse only work for that specific warehouse and schema; there is no cross-warehouse support.
* A custom function definition, including the formula, description, arguments, and parameters, must be 64KB or smaller.

## Create custom functions

The following steps describe how to create a custom function:

1. Navigate to **Administration**.
2. Select **Account** on the left navigation tab.
3. In the **Account** section, scroll to the bottom of the page.
4. Under the **Custom functions** heading, you can see all custom functions that you previously defined on your account.
5. In the **Create custom function** section, click **Add**.
6. In the **Add new custom function** page, specify the new function:

   ![The Add custom functions interface](https://files.buildwithfern.com/sigma.docs.buildwithfern.com/324e0891e08927068cfd670f1b31051da8b4330852490451f78301367ed807c5/assets/docs-images/213e6f7-2.png)

   <dl>
     <dt id="name">
       Name
     </dt>

     <dd>
       Required.
     </dd>

     <dd>
       Name your function.
     </dd>

     <dd>
       Valid function names must adhere to these rules:

       <ul><li>Contain only letters and numbers</li><li>Begin with a capital letter</li><li>Unique (case-insensitive) compared to all other custom and built-in functions</li><li>Maximum 128 characters long</li></ul>
     </dd>

     <dt id="description">
       Description
     </dt>

     <dd>
       Optional.
     </dd>

     <dd>
       Describe what your function does.

       <br />

       If your organization habitually uses multiple data warehouses, and you are using one or more UDFs, specify the warehouse and schema of the UDF. See the 

       <a href="#splinemodel-wrap-complex-syntax-of-custom-warehouse-functions">SplineModel example</a>

       .
     </dd>

     <dt id="arguments">
       Arguments
     </dt>

     <dd>
       Optional.
     </dd>

     <dd>
       Iteratively add arguments to your function by clicking 

       <strong>+ Add argument</strong>

        for each argument.
     </dd>

     <dd>
       To delete an argument, click 

       <strong>x</strong>

        (remove/delete) next to its description.
     </dd>

     <dd>
       For each argument, specify the following:
     </dd>

     <dd>
       <dl>
         <dt>
           Name
         </dt>

         <dd>
           Required.
         </dd>

         <dd>
           Name of the argument.
         </dd>

         <dd>
           Valid argument names must adhere to these rules:
         </dd>

         <dd>
           <ul>
             <li>
               Contain only letters, numbers, spaces, and underscores
             </li>

             <li>
               Cannot begin with a space
             </li>

             <li>
               Maximum 128 characters long
             </li>
           </ul>
         </dd>

         <dd>
           The default arguments are arg1, arg 2, and so on. Rename the arguments to accurately represent the input data.
         </dd>

         <dt>
           Type
         </dt>

         <dd>
           Required.

           <br />


           The data type of the argument.

           <br />


           The default data type is 

           <strong>Number</strong>

           . You can switch to 

           <strong>Text</strong>

           , 

           <strong>Logical</strong>

           , 

           <strong>Datetime</strong>

           , 

           <strong>Variant</strong>

           , or 

           <strong>Geography</strong>

            data type, depending on the input data.
         </dd>

         <dt>
           Description
         </dt>

         <dd>
           Optional.
         </dd>

         <dd>
           Describe the data that the argument represents.
         </dd>
       </dl>
     </dd>

     <dt id="formula">
       Formula
     </dt>

     <dd>
       Required.
     </dd>

     <dd>
       Use built-in functions, operations, and the 

       <a href="#arguments">arguments</a>

        you defined to build the formula for your custom function.
     </dd>

     <dt id="return">
       Return type
     </dt>

     <dd>
       The data type of the return value.
     </dd>

     <dd>
       Sigma populates this field automatically, based on the 

       <a href="#formula">formula</a>

        and the 

       <a href="#arguments">arguments</a>

       .
     </dd>

     <dt id="include">
       Include function

       <br />

       in formula bar

       <br />

       suggestions
     </dt>

     <dd>
       Optional.

       <br />

       Turn the switch to the 

       <strong>on</strong>

        position after you tested and finalized the new custom function.

       <br />

       This makes the new function appear 

       <em>as a suggestion</em>

        on the formula bar in relevant workbooks.

       <br />

       Note that you can use a hidden custom functions by name, and hiding a function does not break existing formulas and elements that consume this custom function.
     </dd>
   </dl>
7. Click **Save**.
8. After saving the custom function, it appears in the list of custom functions.
9. Depending on your choice for the [Include function in formula bar suggestions](/docs/custom-functions#include) switch, this custom function has the status of **Visible** or **Hidden**.

After you create a custom function, you can use it in the workbook's formula interface exactly like a built-in function. The only difference is that built-in Sigma functions typically include a usage example.

Custom functions have the **Custom** label in the formula interface:

![Custom function on the formula bar](https://files.buildwithfern.com/sigma.docs.buildwithfern.com/8ace7b019be2e8c6158971b87c668b73307cd2051e721099047e27bee891619a/assets/docs-images/827edf9-4.png)

## Edit custom functions

To modify an existing custom function, follow these steps:

1. Navigate to the **Custom functions** page: **User > Administration > Account > Custom functions**.
2. For the function you plan to edit, click <img src="https://sigma-docs-screenshots.s3.us-west-2.amazonaws.com/Icons/more.svg" alt="more menu" /> **More**.
3. Select **Edit**.
4. In the **Update custom function** dialog, make the necessary changes and then click **Save**.
   To delete an argument, click **x** (remove/delete) next to the argument description.

   If you change the signature of the function, such as the name, number and type of arguments, or formula, the elements that use the function might break.
   ![Update custom function interface](https://files.buildwithfern.com/sigma.docs.buildwithfern.com/ad981a3e6d100ec13f72125a891e0fe93b2dc55bbb640ddfbc7daa9b22f1f59d/assets/docs-images/760d0bc-7.png)
5. The updated custom function appears in the list of custom functions.

## Hide custom functions

Hide a custom function to prevent it from appearing as a suggestion in the formula interface. Hiding a function does not remove the function from your Sigma instance or account or break elements that use this function.

Hide a function as a step toward deprecating it, effectively limiting and preventing use of the function in new elements and use cases.

To hide a custom function, follow these steps:

1. Navigate to the **Custom functions** page: **User > Administration > Account > Custom functions**.
2. For the function you plan to hide, click <img src="https://sigma-docs-screenshots.s3.us-west-2.amazonaws.com/Icons/more.svg" alt="more menu" /> **More**.
3. Select **Hide function**.
4. In the list of custom functions, Sigma changes the function status to **Hidden**.

You can also hide the function when using the [Add custom function](/docs/custom-functions#create-custom-functions) and [Update custom function](/docs/custom-functions#edit-custom-functions) interfaces.

## Delete custom functions

Deleting a custom function removes it from your Sigma instance or account, and breaks the elements that use this function.

To delete a custom function, follow these steps:

1. Navigate to the **Custom functions** page: **User > Administration > Account > Custom functions**.
2. For the function you plan to delete, click <img src="https://sigma-docs-screenshots.s3.us-west-2.amazonaws.com/Icons/more.svg" alt="more menu" /> **More**.
3. Select **Delete**.
4. The function no longer appears in the list of custom functions.

## Examples of custom functions

### Slice: a custom function for Text

This example demonstrates how to use a custom function **Slice** to extract a portion of text. It uses the built-in Sigma function [Substring](/docs/substring).

![Defining the custom function Slice](https://files.buildwithfern.com/sigma.docs.buildwithfern.com/cb2bcffdf5e75ebd48b2fcae39d497214134bb1ff41b774d51c19be77db700eb/assets/docs-images/e4bbeed-12.png)

| Name  | Description                                                          |
| ----- | -------------------------------------------------------------------- |
| Slice | Get a slice of a text string, at the specified start and end points. |

Function arguments:

| Argument name | Data type | Description                      |
| ------------- | --------- | -------------------------------- |
| text          | Text      | The text to slice.               |
| start         | Number    | The starting index of the slice. |
| end           | Number    | The ending index of the slice.   |

Define the formula and return type:

| Formula                                           | Return type |
| ------------------------------------------------- | ----------- |
| `Substring([text], [start], [end] - [start] + 1)` | Text        |

### SplineModel: wrap complex syntax of custom warehouse functions

When you want to access a UDF from your data warehouse, it's a best practice to use a custom function as a wrapper to ensure that the calling syntax is correct and all necessary definitions migrate into Sigma.

If you do so, identify the warehouse and relevant schema in the description of the function, especially if you use multiple data stores. This serves a reminder for the function users that the function is specific to the connection that references the named UDF.

This example uses the built-in passthrough Sigma function [CallVariant](/docs/callvariant) to ensure the correct data type from the original warehouse function is retrieved:

![Defining the custom function SpliceModel](https://files.buildwithfern.com/sigma.docs.buildwithfern.com/ef4f4b445ddd29ea50e1ae3cdf7e00e999fcf7ea56463cacd96411c023f34291/assets/docs-images/bd0f5b6-13.png)

| Name        | Description                                                                                                                |
| ----------- | -------------------------------------------------------------------------------------------------------------------------- |
| SplineModel | Snowflake: Apply the spline model to the input. <br />(The description identifies the warehouse where the UDF is defined.) |

Function arguments:

| Argument name | Data type | Description     |
| ------------- | --------- | --------------- |
| arg1          | Number    | First argument  |
| arg2          | Number    | Second argument |

Define the formula and return type:

| Formula                                                                        | Return type |
| ------------------------------------------------------------------------------ | ----------- |
| `CallVariant("PRODUCT.SIGMA.SPLINEMODEL", ArrayAgg([arg1]), ArrayAgg([arg2]))` | Variant     |