> For the complete documentation index, see [llms.txt](https://docs.spydra.app/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.spydra.app/how-to/private-network/workflow/calculations-and-formulas.md).

# Calculations & Formulas

User can enter a formula by clicking the formula input box. Whatever is entered in the formula input box will be saved in the format $fn{formula}. The formula can contain constants, variables, operators, and functions.&#x20;

<figure><img src="https://640808362-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5jDaQI2dLzXe5VgQBNFE%2Fuploads%2FCmddnwGdZRSaVyX6r9mq%2FGitbook-switch%20fields1.jpg?alt=media&amp;token=1ecc8ecf-3051-4cac-b41d-13ec5b4db943" alt=""><figcaption></figcaption></figure>

#### <mark style="color:purple;">Operators</mark>

* +, -, \*, /, % (modulus), ^ (exponent)   -> + works with strings and numbers while others will work with numbers only
* \| (pipe) can be used to pass the result of the left-hand side expression as the first argument of the right-hand side expression.

#### <mark style="color:purple;">Functions</mark>

User's can view all the supported functions by typing '@'. The supported functions are&#x20;

**Number Functions**

* @sum(\[n1, n2, …]): Calculates the sum of the given numbers or variables.
* @max(\[n1, n2, …]): Finds the maximum value among the given numbers or variables.
* @min(\[n1, n2, …]): Finds the minimum value among the given numbers or variables.
* @mean(\[n1, n2, …]): Calculates the mean (average) of the given numbers or variables.
* @median(\[n1, n2, …]): Finds the median value among the given numbers or variables.
* @abs(n): Returns the absolute value of the given number or variables.

**String Functions**

* @trim(str, chars): Removes specified characters from the start and end of a string.
* @trimPrefix(str, prefix): Removes a specified prefix from the start of a string.
* @trimSuffix(str, suffix): Removes a specified suffix from the end of a string.
* @upper(str): Converts a string to uppercase.
* @lower(str): Converts a string to lowercase.
* @split(str, delimiter, n): Splits a string into an array of substrings based on a specified delimiter, with an optional limit on the number of splits.
* @splitAfter(str, delimiter, n): Splits a string into an array of substrings based on a specified delimiter, with an optional limit on the number of splits, and includes the delimiter in each substring.
* @replace(str, old, new): Replaces occurrences of a specified substring with a new substring in a string.
* @repeat(str, n): Repeats a string a specified number of times.
* @indexOf(str, substring): Returns the index of the first occurrence of a specified substring in a string.
* @lastIndexOf(str, substring): Returns the index of the last occurrence of a specified substring in a string.

**Type Conversion**

* @type(v): Returns the data type of the value 'v'.
* @int(v): Converts the value 'v' to an integer.
* @float(v): Converts the value 'v' to a floating-point number.
* @string(v): Converts the value 'v' to a string.
* @toJSON(v): Converts the value 'v' to a JSON string.
* @fromJSON(v): Converts the JSON string 'v' to its corresponding value.

**Miscellaneous**

* @len(v): Returns the length of an array or string


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.spydra.app/how-to/private-network/workflow/calculations-and-formulas.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
