# IF function

## IF

The Klipfolio IF function tests each value of the condition and if true returns the corresponding value of the "if true" parameter.  Conversely, if found false, returns the corresponding value of the "if false" parameter.

The syntax for the IF function is:

`IF( condition , if true , if false )`

### Parameters

 condition The value you want to test. vector if true The value returned if the condition evaluates to true. vector if false The value returned if the condition evaluates to false. vector

## How to use the IF function

The IF function performs a logic equation based on a preset condition and then return values based on the result of the equation. The function will either return the value specified in the if true parameter or if false parameter, and displays the result in your Klip. The IF function is used to provide insight about the state of a metric, especially if that metric is frequently changing. For example, if you set up a condition that says the SUM of B:B > 200, then if the result is true, it will display text stating "Gain", but if false, then will display text stating "Loss". When using an IF function, you need to assign data to the following parts of the formula: the Condition, the if true statement, and the if false statement.

### To use an IF function

Note: These procedures assume you are in the Klip Editor as a result of building a Klip or editing a Klip.

1. Select a component from the Component Tree (Column, Primary Value, etc).
2. Click the Start Formula link in the formula editor.
3. Click the Insert function button on the formula editing toolbar.
4. Select Logic>IF from the Function's menu.

1. Click on the Condition link in the IF function.
2. Select a value to include in the Condition.
Tip! Use a nested formula with operators and free text to create a Condition.
1. Click on the if true link in the IF function.
2. Select a value to include in the if true parameter.
Tip! Use the free text option to insert custom text or even an image URL.
1. Click on the if false link in the IF function.
2. Select a value to include in the if false parameter.

Tip! Use the free text option to insert custom text or even an image URL.

## Examples of the IF function

The IF function is useful because it tests your values in the condition and returns a value based on the results of that test (if true, if false parameters). The following examples show different ways you can use an IF function.

### Using an IF function with a math function

The IF function can use any math function (AVERAGE, SUM, MIN/MAX/MEDIAN) along with an operator to create a condition that effectively queries your data. By comparing two data sets in the condition, you can provide an assessment of a metric's performance and display the result of that test in a Klip.

### Using an IF function with TRIM and BLANK functions

By using the TRIM and BLANK functions with an IF function, you can create a logic equation that only shows results in one of the parameters, either the if true or if true parameter. The TRIM removes blank cells from Klip, while the BLANK function renders cells blank. By wrapping an IF in a TRIM function, and using the BLANK function as a parameter, any values not meeting the condition will be removed from the Klip.

### Using image URLs in an IF function

One of the unique ways that you can use an IF function is to return an image based on the result of the equation. You can use any image URL that is accessible via the web or you can use of one Klipfolio Dashboard's indicator images. Note that this indicators are also available using the indicators tab (which uses an IF equation); however, using an image URL grants you more flexibility for manipulating the data in the formula.