# ArrayJoin

The **ArrayJoin** function joins elements of an array into a single text string.

### Syntax

```
ArrayJoin(array, [separator], [nullReplacement])
```

Function arguments:

|                     |                                                                                                                                                                                                                                                                                                                                          |
| ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **array**           | <p>An array containing elements to join into a single text string.</p><ul><li>If you reference a column, it must be a variant column containing data structured as a JSON array (for example, <code>\[“red”, “blue”, “yellow”]</code>). Other column types or data structured as JSON objects return <code>null</code> values.</li></ul> |
| **separator**       | <p>\[optional] A character or string to return between joined elements.</p><ul><li>If unspecified, Analytics Pro applies a comma without spaces by default.</li></ul>                                                                                                                                                                    |
| **nullReplacement** | <p>\[optional] A character or string to replace elements with <code>null</code> values.</p><ul><li>If unspecified, Analytics Pro omits <code>null</code> values by default.</li></ul>                                                                                                                                                    |

### Notes

* Nested JSON arrays or objects in the **array** arguments are converted into text strings using your data platform’s JSON-to-text method. This can impact the nested JSON structure, key-value pair order, and white space (like spaces, tabs, and line breaks).
* If any argument is `null`, the function returns `null`.

### Examples

#### Example 1

```
ArrayJoin([JSON array], “, ”)
```

Returns a single text string containing each non-null element from the *JSON array* column separated by a comma and a space.

<figure><img src="https://files.readme.io/46338cc-image.png" alt=""><figcaption></figcaption></figure>

#### Example 2

```
ArrayJoin(Array(“red”, null, “blue”, “yellow”), “ or ”, “*”)
```

Returns `red or * or blue or yellow`.

#### Example 3

```
ArrayJoin(Json('[[1,"a"], {"b":2}, "c", 3]'), ";")
```

Returns `[1,"a"];{"b":2};c;3`.
