|
| 1 | +--- |
| 2 | +title: 'Array functions' |
| 3 | +description: 'This article explains various array functions that can be used in formula fields.' |
| 4 | +tags: ['Fields', 'Field types', 'Formula', 'Array'] |
| 5 | +keywords: ['Fields', 'Field types', 'Formula', 'Array', 'Create formula field', 'Array functions'] |
| 6 | +--- |
| 7 | + |
| 8 | +This cheat sheet provides a quick reference guide for various array functions commonly used in data analysis and programming. Each function is accompanied by its syntax, a sample usage, and a brief description. |
| 9 | + |
| 10 | + |
| 11 | +## ARRAYSORT |
| 12 | +The ARRAYSORT function sorts an array result from links or lookup. |
| 13 | + |
| 14 | +#### Syntax |
| 15 | +```plaintext |
| 16 | +ARRAYSORT(array, ["asc" | "desc"]) |
| 17 | +``` |
| 18 | + |
| 19 | +#### Sample |
| 20 | +```plaintext |
| 21 | +ARRAYSORT({LookupField}, "desc") |
| 22 | +``` |
| 23 | + |
| 24 | +#### Remark |
| 25 | +This function sorts an array result given from links or lookup field. |
| 26 | +The 2nd parameter is the sort order, "asc" or "desc" to sort the values ascending or descending, with "asc" as the default if not provided. |
| 27 | + |
| 28 | +--- |
| 29 | + |
| 30 | +## ARRAYUNIQUE |
| 31 | +The ARRAYUNIQUE function returns unique items from the given array. |
| 32 | + |
| 33 | +#### Syntax |
| 34 | +```plaintext |
| 35 | +ARRAYUNIQUE(array) |
| 36 | +``` |
| 37 | + |
| 38 | +#### Sample |
| 39 | +```plaintext |
| 40 | +ARRAYUNIQUE({Field}) |
| 41 | +``` |
| 42 | + |
| 43 | +#### Remark |
| 44 | +This function removes duplicate values, leaving only unique items from the given array. |
| 45 | + |
| 46 | +--- |
| 47 | + |
| 48 | +## ARRAYCOMPACT |
| 49 | +The ARRAYCOMPACT function removes null and empty from result. |
| 50 | + |
| 51 | +#### Syntax |
| 52 | +```plaintext |
| 53 | +ARRAYCOMPACT(array) |
| 54 | +``` |
| 55 | + |
| 56 | +#### Sample |
| 57 | +```plaintext |
| 58 | +ARRAYCOMPACT({Field}) |
| 59 | +``` |
| 60 | + |
| 61 | +#### Remark |
| 62 | +This function removes null and empty, leaving only visible items from given array. |
| 63 | + |
| 64 | +--- |
| 65 | + |
| 66 | +## ARRAYSLICE |
| 67 | +The ARRAYSLICE function takes partial array values from start to (optional) end. |
| 68 | + |
| 69 | +#### Syntax |
| 70 | +```plaintext |
| 71 | +ARRAYSLICE(array, start, [end]) |
| 72 | +``` |
| 73 | + |
| 74 | +#### Sample |
| 75 | +```plaintext |
| 76 | +ARRAYSLICE({Field}, 2, 3) |
| 77 | +``` |
| 78 | + |
| 79 | +#### Remark |
| 80 | +This function takes the array value partially, from start to (optional) end. |
| 81 | +2nd parameter is the start index. Index start at 1. |
| 82 | +3rd parameter is the end index. In the example above it'll take array value 2 and 3, giving a total 2 items. |
| 83 | +Omitting end index will take the rest of items starting from start index. |
| 84 | +Either start or end index cannot be negative. End index need to be bigger or equal with start index. Doing so will return empty as result. |
| 85 | + |
| 86 | +--- |
0 commit comments