IF function


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 )


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.

What's next?

Did you have trouble with the material in this article?

These articles may help:


  1. Introduction: Using formulas
  2. Data Manipulation functions
  3. Logic functions
  4. Math functions
  5. SELECT function
  6. Text Functions
  7. Date and Time Functions
  8. Statistics Functions
  9. ABS function
  10. AND function
  11. ARRAY function
  12. AVERAGE function
  13. BETWEEN function
  14. BLANK function
  15. CAPITALIZE function
  16. CEILING function
  17. CONCAT function
  18. CONTAINS function
  19. COUNT function
  20. COUNTALL function
  21. COUNTBLANK function
  22. COUNTDISTINCT function
  23. COUNTIF function
  24. COUNT_DAYS function
  25. COUNTNUMERIC function
  26. CUMULATIVE function
  28. DATASOURCE function
  29. DATE and DATEVALUE functions
  30. Using Date and Time Formats
  31. DATERANGE function
  32. DATE_ADD function
  33. DATE_CLOSEST function
  34. DATE_CONVERT function
  35. DATE_ENDOF function
  36. DATE_IN function
  37. DATE_SET function
  38. DATE_STARTOF function
  39. DATE_UNITVALUE function
  40. FLOOR function
  41. ERF function
  42. FIRST function
  43. ERFC function
  44. GROUP and GROUPBY functions
  45. IF function
  46. IN function
  47. INDEXOF function
  48. JOIN function
  49. LAST function
  50. LASTINDEXOF function
  51. LEFT function
  52. LOOKUP function
  53. LOWER function
  54. MAP function
  55. MAX function
  56. MIN function
  57. MEDIAN function
  58. MOD function
  59. MODE function
  60. Moving Average (Cumulative)
  61. Moving Average (Exponential)
  62. Moving Average (Simple)
  63. NORMSDIST function
  64. NOT function
  65. NOW function
  66. NUMBERFORMAT function
  67. OR function
  68. PADVALUES function
  69. POWER function
  70. RANK function
  71. REMOVE_EMOJI function
  72. REPEAT function
  73. REPLACE function
  74. REVERSE function
  75. RIGHT function
  76. ROUND function
  77. SET function
  78. SLICE function
  79. SLOPE function
  80. SORT function
  81. SPLICE function
  82. STANDARDIZE function
  83. STDEV function
  84. STDEVP function
  85. SUBSTITUTE function
  86. SUBSTITUTE_REGEX function
  87. SUBSTRING function
  88. SUM function
  89. SUMIF function
  90. SWITCH function
  91. TEXT_REVERSE function
  92. TODAY function
  93. TRIM function
  94. TRUNCATE function
  95. UPPER function
  96. URLDECODE function
  97. URLENCODE function
  98. VARIANCE function
  99. VARIANCEP function
  100. YESTERDAY function
  101. ZTEST function

Feedback and Knowledge Base