This repository has been archived by the owner on Oct 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
TEXTJOIN
Dan Gorman edited this page Nov 29, 2018
·
2 revisions
TEXTJOIN
joins strings or arrays of strings with a specified delimiter.
TEXTJOIN(arg1, arg2, arg3, [arg4])
-
arg1
is the delimiter to use to join text -
arg2
is a boolean value, which determines whetherTEXTJOIN
will ignore empty string values -
arg3
is a string or an array of strings -
arg4
is optional, and is also a string or an array of strings
Let's say we're given a response with a 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 would return "Toyota, Hyundai, Kia, Mercedes Benz"
.
If we try to parse the second example with the second argument set to true, it will come out with those blanks:
TEXTJOIN(", ", TRUE, data.parts.part_2) => "BMW, Mercedes Benz, Ford, Tesla"
But with the second argument as false, we'll get this:
TEXTJOIN(", ", FALSE, data.parts.part_2) => "BMW, , Mercedes Benz, , Ford, , Tesla"