TEXTJOIN

TEXTJOIN joins strings or arrays of strings using a specified delimiter.

Function category: Text

Syntax

TEXTJOIN(arg1, arg2, arg3, [arg4])

Arguments

Description

arg1

Delimiter used to join text.

arg2

A boolean value which determines if TEXTJOIN ignores empty string values.

arg3

String or array of strings.

arg4

Optional. String or array of strings.

Examples

Example 1: Compile a more readable version of an array of values.

Let's say we're given a response with the following list of car manufacturers for a given part:

{
"data":{
"parts":{
"part_1":[
"Toyota",
"Hyundai",
"Kia",
"Mercedes Benz"
],
"part_2":[
"BMW",
"",
"Mercedes Benz",
"",
"Ford",
"",
"Tesla"
]
}
}
}

If we want to compile an easier to read version of the distributors for a given part, we can use TEXTJOIN:

TEXTJOIN(", ", TRUE, data.parts.part_1)

This returns the following:

"Toyota, Hyundai, Kia, Mercedes Benz"

Example 2: Ignore empty string values

If we try to parse part_2 with arg2 set to true, it will remove any blanks:

TEXTJOIN(", ", TRUE, data.parts.part_2)

This results in the following:

"BMW, Mercedes Benz, Ford, Tesla"

Example 3: Don't ignore empty string values

If we try to parse part_2 with arg2 set to true, it will retain any blanks:

TEXTJOIN(", ", FALSE, data.parts.part_2)

This results in the following:

"BMW, , Mercedes Benz, , Ford, , Tesla"