SELECT function

SELECT

The SELECT function allows you to select a subset of data based on a specified criteria.

The syntax for the SELECT function is:

SELECT (data , condition )

Parameter

data an array of data.
condition the criteria to select from the data. This parameter must return an array of true and false values, and is typically a comparison between values. Note: it is unnecessary to use the IF function in the condition parameter.

The data and condition parameters must be the same size because each item in the condition array is applied to each item at the same position in the data array.

To learn more about the SELECT function, you can watch these videos!

Use the SELECT function based on a criteria or condition
Use the SELECT function with multiple conditions

Example

Using the following data source, SELECT( A:A, (B:B = 15) ), selects Oranges from column A, because the corresponding value in column B equals 15.

A B C
1 Fruit Units Date
2 Apples 10 9-Nov-15
3 Oranges 15 9-Jul-15
4 Pears 20 9-Sep-15

SELECT( A:A, (B:B = 15 ) ) performs the following comparisons:

Select Fruit if (Units = 15): since (Units = 15) returns false, Fruits is not selected.

Select Apples if (10 = 15): since (10 = 15) returns false, Apples is not selected.

Select Oranges if (15 = 15): since (15 = 15) returns true, Oranges is selected.

Select Pears if (20= 15): since (20 = 15) returns false, Pears is not selected.

Common scenarios

The following examples show you how to use the SELECT function, with a variable created in a User Input Control component, when selecting data in your Klips.

In this example, the SELECT function returns the value in column B that matches the fruit-type selected from a drop-down list.
For example, if you select Apples, the value returned is 10.

SELECT( B:B , ( variable = A:A ))

In this example, the SELECT function includes the OR function to give the user the option to return all fruit-types. If "All" is selected from a drop-down list, the values for all fruit-types are returned.
For example, Apples = 10, Oranges = 15, and Pears =20.
Note: The SLICE function removes the column header.

SELECT( SLICE( B:B ) , OR( ( variable = SLICE( A:A ) , ( "All" = variable ) ) )

In this example, the SELECT function includes the AND function to restrict the data to the last three months starting from today's date.
For example, as the current month is November, the value for July is not returned.
Note: Use the date format in your own data source.

SELECT( B:B , AND( OR( ( variable = A:A ) , ( "All" = variable ) ), BETWEEN( DATE( C:C , "d-MMM-yy" ) , DATE_ADD( TODAY( ) , month , -3 ) , TODAY( ) ) ) )

To see an example of a Klip that uses the SELECT function with a variable, and the AND and OR functions, refer to the following article: Common User Input Control scenarios: Displaying total boxes fruit sold in the last three months

Related links:

Functions

  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
  27. CUMULATIVE_DIFFERENCE 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