> ## Documentation Index
> Fetch the complete documentation index at: https://help.nextmatter.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Calculations and comparisons

> Create steps in your workflow that allow calculations and comparing data.

## Calculating formulas

This operation allows you to carry out arithmetic operations.

1. In your workflow editor, click **+ Add step**.
2. Select **Integrations > Quick action**.
3. Click **Configure**.
4. Click the **Quick Action operation** field and select **Calculate formula**.
5. Enter your formula. **Tip**: you can include numbers, text, operators, and data references (the values in input fields from previous steps)

* If you want to use the comparison result in later steps add the result variable in the **Response data for use in later steps**. The variable's value should be `$.result`

## Comparing formulas

1. In your workflow editor, click **+ Add step**.
2. Select **Integrations > Quick action**.
3. Click **Configure**.
4. Click the **Quick Action operation** field and select **Compare formula**.
5. Enter your formula. **Tip**: you can include numbers, brackets, operators, and data references (the values in input fields from previous steps)

## Supported operations

### Calculating formulas

|      |                              |            |
| ---- | ---------------------------- | ---------- |
| -    | add                          | 1+1 = 2    |
| -    | subtract                     | 4-2 = 2    |
| /    | divide                       | 4/2 = 2    |
| -    | multiply                     | 2\*2 = 4   |
| \*\* | exponents (to the power of)  | 3\*\*2 = 9 |
| %    | remainder (amount left over) | 5%2 =      |

### Comparing data

| Operator     | Description                                                                                                                                                                                                         | Expression example                                                                                                                               | Result                                                                            |
| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------- |
| `==`         | equals                                                                                                                                                                                                              | `2==2`                                                                                                                                           | True                                                                              |
| `<`          | less                                                                                                                                                                                                                | `1<2`                                                                                                                                            | True                                                                              |
| `>`          | greater                                                                                                                                                                                                             | `1>2``{1. New form - Date Input - Date (plain)} (%s) > {Instance start time} (%s)`                                                               | False True (used to compare dates)                                                |
| `<=`         | less than or equal to                                                                                                                                                                                               | `2<=2`                                                                                                                                           | True                                                                              |
| `> =`        | greater than or equal to                                                                                                                                                                                            | `1>=2`                                                                                                                                           | False                                                                             |
| `endswith`   | Looks for text ending with a provided phrase; comparing ends of strings                                                                                                                                             | `endswith(".txt", "text.txt")` `endswith(".txt", "{{data_reference_to_filename}}")`                                                              | returns `True` if the string ends with the specified suffix, otherwise `False`.   |
| `startswith` | Looks for text starting with a provided phrase; comparing the beginnings of strings                                                                                                                                 | `startswith("pata", "patata")` `startswith("pata", "{{data_reference_to_filename}}")`                                                            | returns `True` if the string starts with the specified suffix, otherwise `False`. |
| `in`         | Checks if a value exists within a sequence Note that list evaluations such as `1 in [1,2,3]` are not supported using `in `and `not in` operators.                                                                   | `"ana" in "banana"`                                                                                                                              | True                                                                              |
| `and`        | boolean operator; Use to combine multiple comparison expressions when you need all conditions to be true.                                                                                                           | `("monday"=="monday") and 2>1`                                                                                                                   | True                                                                              |
| `or`         | boolean operator; When using `or`, the combined condition evaluates to `True` if at least one of the individual conditions is True. If all conditions are `False`, the combined condition will evaluate to `False`. | `("{{data_reference_to_fruit}}") == ("apple") or ("{{data_reference_to_fruit}}") == ("banana") or ("{{data_reference_to_fruit}}") == ("cherry")` | True                                                                              |

### Comparing regular expressions

| Regex example                                                                                                                                                                                                                                                                                                     | Description                                                                                     | Result |
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- | ------ |
| `match_regex('\\d{3}-\\d{2}-\\d{4}', '123-45-6789')`                                                                                                                                                                                                                                                              | Checks whether the string matches a specific regular expression pattern                         | True   |
| `match_regex('\\d{3}-\\d{2}-\\d{4}', '45-6789')`                                                                                                                                                                                                                                                                  | Checks whether the string matches a specific regular expression pattern                         | False  |
| `match_regex('te.\*st', 'tessssst')`                                                                                                                                                                                                                                                                              | Checks whether the string matches a specific regular expression pattern                         | True   |
| `match_regex('te.+st', 'test')`                                                                                                                                                                                                                                                                                   | Checks whether the string matches a specific regular expression pattern                         | False  |
| `match_regex("((([A-Za-z]{3,9}:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+\|(?:www.\|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/\[\+~%\/.\\w-_]_)?\??(?:\[-\+=&;%@.\\w_]\_)#?(?:[.\!\/\\w]\*))?)", "[www.url-with-querystring.com/?url=has-querystring"](http://www.url-with-querystring.com/?url=has-querystring")` | Checks if the string contains a URL that matches the pattern defined by the regular expression. | True   |
| `match_regex("((([A-Za-z]{3,9}:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+\|(?:www.\|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/\[\+~%\/.\\w-_]_)?\??(?:\[-\+=&;%@.\\w_]\_)#?(?:[.\!\/\\w]\*))?)", "not_valid.url-with-querystring.com/?url=has-querystring")`                                                       | Checks if the string contains a URL that matches the pattern defined by the regular expression. | False  |

<Info>
  For limitations in the supported regular expressions, see [Syntax (external page)](https://github.com/google/re2/wiki/Syntax). You can use [this external page](https://regex101.com/r/AsHMJK/3) to test if your expression is correct.
</Info>
