Get Ready For Your Tableau Certification
  • Bernard

How to use concatenate in Tableau?

How to use concatenate in Tableau

String concatenation is the operation of joining character strings end to end. For example, you can concatenate the string ‘Snow’ and ‘ball’ to get ‘Snowball’.

Concatenation is therefore useful when you need to combine multiple fields to create a single field.

tableau online courses

The syntax

String concatenation in Tableau can be done using the operator (+) as follows.

String_1 + String_2 + String_3 + ……………………. + String_n-1 +String_n

The Problem

In this case, I would like to use Tableau to visualize these two data sets.

Table (i): Shows Sales for different Orders. (Where Order_ID - consists of Region (ES), Month of Order (Jan) and Year of Order (2021)).

sample data 1

Table (ii): Shows Target Sales for different Orders. (Where in this case Order_ID isn’t available, instead we have the fields Region, Month and Year).

sample data 2

The solution

To join or blend these two datasets to visualize them – I’ll need to concatenate the fields ‘Region’, ‘Month’ and ‘Year’ from table (ii) to create a single field that matches the field ‘Order_ID’ from table (i).

So, how do you concatenate the fields?

(In this case – I’ll blend the data to visualize it).

Create the view below using data from table (i).

basic tableau view

Connect the second data and come to the same worksheet to blend the data sets.

Create a new calculated field that will combine the three fields, Region, Month and Year to create a single field called ‘Order_ID’

(Basically, what we call concatenation)

Concatenation in Tableau

Link the two fields between the two data sets (Note, linking will happen automatically if the field name I’ve created match ‘Order_ID’ from the primary data).

establishing a link between fields

Now you can visualize the data – in this case I’ll drag Target Sales to the axis.

Resulting to the view below.

(With this view – I can compare the actual sales against the target sales for different orders)

By concatenating the multiple fields – I was able to create a new field that matches Order_ID from the primary data, enabling me to blend the two data sets to visualize them.

I hope this article was helpful to you. To receive more of the Tableau tips, kindly join our mailing list by subscribing below.

Thank you for reading.