TEXTJOIN Function

Overview

TEXTJOIN is a formula that combines multiple variables or strings into one string. You can also specify a delimiter that's inserted between each joined value. This could be a character (like a comma or ampersand) or even just a space. You can also choose to include or skip empty cells.

Let's look at a practical example of when you'd use the TEXTJOIN formula. Suppose you have an application where end-users enter a first and last name in separate Text Fields. But, you also want to create a field that stores their full name as a single value. You can use the TEXTJOIN formula in a Calculator component to join those strings. A space would be a fitting delimiter.

NOTE  The TEXTJOIN formula isn't suitable for joining an array of values into a single string. When using TEXTJOIN on an array, the Calculator only outputs a comma-separated list of all values in the array. The Calculator ignores the delimiter and ignore_empty parts set in the formula. To join values from an array, use the Join operator in a Data Workflow component instead.

What You'll Learn

In this article, you'll learn:

Parts of the TEXTJOIN Formula

The function signature for the TEXTJOIN formula is:

=TEXTJOIN("{delimiter}", {ignore_empty}, {"value1"}, {"value2"}, {…}).

This outputs a string of concatenated values, all separated by a delimiter. Let's take a closer look at each part of the formula:

Argument

Description

delimiter

Specify a text string used to separate your values. For example, a space (" "), comma (","), ampersand ("&"), or even a combination of characters. If you don't set a delimiter, the function concatenates all values without a delimiter. You'll surround the delimiter in quotation marks. If you use a number as a string delimiter, the Calculator treats the number as text.

ignore_empty

Specify whether to exclude empty values from the final output. If you enter TRUE, the Calculator excludes any empty values from the final output. If you enter FALSE, the Calculator doesn't exclude empty values from the output.

value1, value2...

Lists the strings you want concatenated. You can use an alias to dynamically reference input from another component in your module. Or, you can hard-code the value. You can also combine alias values and hard-coded values. For example, =TEXTJOIN(" ", TRUE, "Hello", A, B) joins the word Hello with the values from the inputs assigned the aliases A and B.

TIP  When hard-coding values, you surround the value in quotation marks. If your value isn't in quotation marks, the component assumes the value is a Property ID in the module. Remember, you won't surround aliases in quotation marks.

Using The TEXTJOIN Formula in the Calculator Component

Let's use a TEXTJOIN formula in the Calculator Component. In this use case, you'll build an app that takes a first and last name, then joins them together in a sentence. So, the final output will be "My name is {firstName} {lastName}", separated by spaces. These instructions assume that you have an open module saved with a title.

What You'll Need

For this module, you'll need:

  • 3 Text Field components

  • 1 Calculator component

  • 1 Button component

Configure the Text Field Components

First, you'll create 3 Text Field components: a first name, a last name, and a place for your new sentence.

1. Drag and drop 3 Text Field components onto your canvas.
2. Enter the Property ID and Label Text as follows:

Property ID

Label Text

firstName

First Name

lastName

Last Name

yourName

Your Name

3. Set the Disable User Input toggle to ON in the yourName Text Field. Remember, you're disabling user input as this field auto-populates with your joined sentence.
4. Save each component as you add it.

Configure the Calculator Component

The Calculator Component is where you'll insert your TEXTJOIN formula. The formula combines hard-coded values with aliases, letting you dynamically substitute the end-user's first and last name in the formula.

1. Drag and drop a Calculator component onto your canvas, placing it between the lastName and yourName Text Fields.
2. Enter calcTextJoin in the Property ID and Canvas Label Text fields.
3. In the Inputs table, enter the following:

Property ID

Alias

Required

firstName

A

No (unchecked)

lastName

B

No

4. In the Outputs table, enter the following:

Property ID

Formula

yourName

=TEXTJOIN(" ",TRUE,"My name is",A,B)

TIP  You could also write this formula as =TEXTJOIN(" ", TRUE, "My", "name", "is", A, B).

5. Click Save.

Configure the Button Component

Finally, the Button component triggers the Calculator component.

1. Drag and drop a Button component onto your canvas, placing it below the yourName Text Field.
2. Enter btnRunCalc in the Property ID field.
3. Enter Run Calculator in the Label Text field.
4. Select Event from the Action Type.
5. Enter calcTextJoin in the Trigger On Click field.
6. Click Save.
7. Save your module.

Now you're ready to see the TEXTJOIN formula in action. Preview your module in Express View, fill out the first and last name fields, and click Submit. My name is {firstName} {lastName} appears in the Your Name text field. It should look something like this:

Lab

You can view the completed lab for this module here: https://training.unqork.io/#/form/60c3709e39ee1902dfb861d8/edit.