Skip to content

Commit b04c0ba

Browse files
authored
Merge pull request #145 from nocodb/feat/array-functions
add array functions
2 parents b86812f + ea9d261 commit b04c0ba

File tree

3 files changed

+88
-0
lines changed

3 files changed

+88
-0
lines changed
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
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+
---

content/docs/fields/field-types/formula/formula.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ keywords: ['Fields', 'Field types', 'Formula', 'Create formula field']
3333
- [Numeric Functions](/docs/product-docs/fields/field-types/formula/numeric-functions)
3434
- [String Functions](/docs/product-docs/fields/field-types/formula/string-functions)
3535
- [Date Functions](/docs/product-docs/fields/field-types/formula/date-functions)
36+
- [Array Functions](/docs/product-docs/fields/field-types/formula/array-functions)
3637
- [Conditional Expressions](/docs/product-docs/fields/field-types/formula/conditional-expressions)
3738

3839

content/docs/fields/field-types/formula/meta.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"numeric-functions",
77
"string-functions",
88
"date-functions",
9+
"array-functions",
910
"conditional-expressions",
1011
"generic-functions",
1112
"formula-result-formatting"

0 commit comments

Comments
 (0)