# Using Modifiers to alter data

[You learned that Variables are placeholders for data coming from previously connected components in your flows that will be eventually replaced with real values once they are available at flow runtime](https://docs.appmixer.com/kb/appmixer-studio-features/using-variables-to-map-data).&#x20;

Sometimes you need to modify the values. For example, you receive a percentage value but you'd like to store it in the decimal format (i.e. 75 becomes 0.75). This is exactly where Modifiers excel.

{% embed url="<https://youtu.be/Y9P0mUN94jE>" %}
Using Modifiers to alter data
{% endembed %}

Modifiers are a powerful tool to modify variable values, change their format or even use conditionals and loops to structure the actual output of your variables. It's like applying excel formulas to your variables - but simpler.&#x20;

Modifiers can be stacked, meaning that the result of one modifier is an input to another modifier used for the same variable (e.g. "divide by 10, then add 50, then round").

Let's dig deeper into what Modifiers are by continuing with our simple example. Say we collect a "Percentage" field in a form and pass the data to a Google Sheet. On the way, we want to adjust the percentage from 75 to 0.75. To achieve that, you can simply click on the variable and choose the right data modifier.

![Opening the Modifiers panel](https://660555879-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Meyy9fJyhzsrd3q4-5N%2F-MgLsXHhpEiszOeMbWTx%2F-MgLuV4qO9gq0UC-RfgK%2Fgif-example-1.gif?alt=media\&token=95fa6f24-b48f-44b8-a79e-ba66d1f4d311)

As you can see, the Modifiers dialog contains different categories for different types of variable values. In our case, we're interested in the "Number" category and the "Div" modifier that divides our Percent variable by another number that we specify. Just click the "Div" modifier to apply it to our variable and tell the modifier that we want to modify our value by 100.

![Using the "Div" modifier](https://660555879-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Meyy9fJyhzsrd3q4-5N%2F-MgLsXHhpEiszOeMbWTx%2F-MgLu_vtJjsznhlLfIMQ%2Fgif-example-2.gif?alt=media\&token=2360cbf8-db7b-424c-b8b2-2d18bf1b650a)

Now press "Close" and you'll see the "Percent" variable changed appearance a little bit to tell you that it will be modified at runtime.

![Saving the changes](https://660555879-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Meyy9fJyhzsrd3q4-5N%2F-MgLsXHhpEiszOeMbWTx%2F-MgLufZ8HylLqRzgxn0q%2Fgif-example-3.gif?alt=media\&token=a6bc7860-12ad-435c-9a60-24613eff1bc9)

**To explain the power of modifiers, let's look at the second example.** This time, we'll want to modify dates. Imagine we keep a record of our employees' vacations and want to notify them by email and SMS two days before their vacation ends to remind them that they should come to work in two days. Our sheet can look like this:

![Record of our employees vacations](https://660555879-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Meyy9fJyhzsrd3q4-5N%2F-MfCYhN-c1y7f4VGtxsh%2F-MfCaRyzht9JHqM7nK7T%2FScreen%20Shot%202021-07-22%20at%2011.43.42.png?alt=media\&token=0484b137-ec3a-4d73-915a-0cc892992865)

Our "To Date" column contains the end date of the employee's vacation. However, we want to send them SMS and email two days before their first day at work. Therefore, we want to subtract one day from the "To Date" and wait for that new date to send them reminders. Our flow can look like this.

![Flow overview](https://660555879-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Meyy9fJyhzsrd3q4-5N%2F-MgLsXHhpEiszOeMbWTx%2F-MgLveV3p-BRxGiCU2fK%2Fpic-example-1.png?alt=media\&token=822104c7-be44-42c1-b88a-5aa32dca4e78)

Notice how we use the "Wait" component to wait for a certain date. In the "Until" field, we use the modified "To Date" column value. We modified our variable with the "AddSpan" modifier from the "Date" category and filled "-1" for the "Days" parameter.

![Using the modifier to adjust the date](https://660555879-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Meyy9fJyhzsrd3q4-5N%2F-MgLsXHhpEiszOeMbWTx%2F-MgLvwLSWeXUshjQJzRI%2Fgif-example-2.gif?alt=media\&token=1a1cd305-c8f1-4825-905a-6908a04346a5)

You might have noticed that there are many modifier categories and types at your disposal. We intend to give you maximal flexibility with our pre-built modifiers or empower you to simply build your categories and types.

Below, see the complete list of Modifier categories and types.

{% tabs %}
{% tab title="Object" %}
**Each**\
Loops over all values of a list or an object

**JSON Path**\
Accesses nested properties of the VALUE object using dot notation

**Map**\
Maps array to another array

**Stringify**\
Converts an object or list to a JSON string
{% endtab %}

{% tab title="List" %}
**Deduplicate**

Filter unique values or objects in an array if property name is provided

**Each**\
Loops over all values of a list or an object

**Filter**\
Iterates over items in the list and returns a new list with values that pass the predicate

**First Item**\
Finds the first item of a list

**Flatten**\
Flattens array a single level deep or recursively

**Initial**\
Gets the first element(s) of an array

**Join**\
Joins items into a text

**Last Item**\
Finds the last item of a list

**Length**\
Finds length of a text or list

**Map**\
Maps array to another array

**Max**\
Computes the maximum value of array

**Mean**\
Finds average (arithmetic mean) of the values of array

**Min**\
Computes the minimum value of array

**Nth Index**\
Finds the nth item of a list

**Pick**\
Transforms the list by picking nested object values

**Reverse**\
Reverses array so that the first first element becomes the last, the second element becomes the second to last, and so on.

**Shuffle**

Shuffle values of an array

**Stringify**\
Converts an object or list to a JSON string

**Sum**\
Computes the sum of the values in array

**Tail**\
Gets all but the first element(s) of array
{% endtab %}

{% tab title="Text" %}
**Add**\
Adds two numbers or concatenate two strings

**Base64**

Generate base64 string

**Camel Case**\
Converts text to camel case. (Example: "Foo Bar"-> "fooBar")

**Decode URL**\
Decodes URL or a URL component

**Encode URL**\
Encodes URL or a URL component

**Escape HTML**\
Converts the characters "&", "<", ">", "", and """ in text to their corresponding HTML entities

**Extract email addresses**\
Returns a list of email addresses found in the text

**Extract URLs**\
Returns a list of email addresses found in the text

**Extract words**\
Splits the text into a list of its words

**Kebab Case**\
Converts text to kebab case. (Example: "Foo Bar" -> "foo-bar")

**Greater than**\
Tests if the first value ir greater than the second value

**Length**\
Finds length of a text or list

**Less than**\
Tests if the first value if less than the second value

**Lower First**\
Converts the first character of the text to lower case

**Lowercase**\
Transforms text to lower case

**MD5**\
Gets an MD5 hash of the text

**Padding**\
Pads text on the left and right sides if it's shorter than a specified length

**Regex**\
Finds matches using regular expression

**Replace**\
Replaces part of the text using regular expressions or text patterns

**SHA1**

Hash a string using SHA1 algorithm

**SHA256**

Hash a string using SHA256 algorithm

**SHA512**

Hash a string using SHA512 algorithm

**Snake Case**\
Converts text to snake case. (Example: ""Foo Bar" -> "foo\_bar")

**Split**\
Splits text by delimiter

**Split By Whitespace**\
Splits text into a list of words by chunks of whitespace

**Trim**\
Removes leading and trailing whitespace or specified characters from string

**Trim End**\
Removes trailing whitespace or specified characters from string

**Trim Start**\
Removes leading whitespace or specified characters from string

**Truncate**\
Truncates text if it's longer than the given maximum text length. The last characters of the truncated text are replaced with the omission which defaults to "..."

**Upper First**\
Converts the first character of the text to upper case

**Uppercase**\
Transforms text to upper case
{% endtab %}

{% tab title="Control" %}
**Condition**\
Conditional statement. If EXPRESSION evaluates to true, TRUE VALUE branch will be the resulting value. Otherwise, FALSE VALUE will be used.

**Custom Fields**

Returns flow custom fields

**Equals**\
Tests equality of two values. Resulting value is true if FIRST EXPRESSION equals SECOND EXPRESSION.

**Flow ID**

Returns current flow ID

**Flow Name**

Returns current flow name

**Not**\
Invert value. True value becomes false and vice versa.

**UUID v4**

Returns UUID v4

**JavaScript Function**\
Run JavaScript code to transform a variable value. Anonymous functions, arrow functions, and plain javascript code are supported.

Arrow function example:

![](https://660555879-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Meyy9fJyhzsrd3q4-5N%2Fuploads%2FTMci99bEh1xG0BR54WfE%2FAppmixer_4_4_0_Release_Notes_-_Google_Docs.png?alt=media\&token=193ed6dd-54ec-4352-8425-edabd028d217)

Another example:

![](https://660555879-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Meyy9fJyhzsrd3q4-5N%2Fuploads%2FJx15K5DD5jAZWbq5s7B4%2FAppmixer_4_4_0_Release_Notes_-_Google_Docs.png?alt=media\&token=d4e4dadc-a894-4d46-bc56-8055c4388308)
{% endtab %}

{% tab title="Number" %}
**Add**\
Adds two numbers or concatenate two strings

**Avg**\
Finds average (arithmetic mean) of a given number

**Ceil**\
Rounds to the smallest integer greater than or equal to a given number

**Div**\
Divides two numbers

**Floor**\
Rounds to the largest integer less or equal to a given number

**Greater than**\
Tests is the first value is greater than the second value

**Less than**\
Tests if the first value is less than the second value

**Max**\
Finds maximum of given numbers

**Min**\
Finds minimum of given numbers

**Mod**\
Finds remainder after division of one number by another

**Mul**\
Multiplies two numbers

**Sub**\
Subtracts two numbers
{% endtab %}

{% tab title="Date" %}
**AddSpan**\
Adds time span to the date

**Format Date**\
Formats a date/time string using a string of tokens

**Greater than**\
Tests if the first date is greater than the second date

**Less than**\
Tests if the first date is greater than the second date

**Now (ISO 8601)**

Returns current date string in the ISO 8601 format

**Relative time**\
Formats a relative date/time

**Timestamp (Unix)**

Returns Unix timestamp
{% endtab %}

{% tab title="Math" %}
**PI**

Returns value of PI

**Random number**

Returns a random number between 0 and 1
{% endtab %}
{% endtabs %}

{% hint style="info" %}
Appmixer is all about flexibility and agility. You can customise all modifiers and also implement your own using Node.js and upload them to the Appmixer engine via API to suit your specific business needs.
{% endhint %}

[In the next section, you'll learn how to implement logic to your flows](https://docs.appmixer.com/kb/appmixer-studio-features/implementing-logic).
