# 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="/files/KDiFCtGfoaOf7rx3OLAU" 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: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

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

The question should be specific, self-contained, and written in natural language.
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.
