Concatenate
Last updated
Was this helpful?
Last updated
Was this helpful?
Concatenation allows you to combine two or more strings (text fields or user-defined text) into a single value. This is useful for generating new fields, e.g. Full Name
from First Name
& Last Name
, or creating combined values to act as a unique lookup key.
Some tools like Excel, OrgVue and Python have two types of concatenation: a + b
style syntax and concat(a,b)
style syntax. Both options are listed below.
NB. Using the join()
method in OrgVue you can specify a delimiter to use between each string to be concatenated. In all other methods, if you want to have a delimiter between combined strings you need to add it separately as many times as needed.
In Excel you have two options for combining strings:
Option 1: &
is the quickest if you only have 2 values to combine
=‹value1›&‹value2›
Option 2: CONCATENATE()
is better for long chains
=~CONCATENATE!~(‹value1›, ‹value2›, ‹value›)
‹string1› + ‹string2›
NB. Both arguments must be strings. To convert a different data type to a string, use ~STR!~(‹field›). Go to for more information.
‹string1› + ‹string2›
In OrgVue you have three options for combining strings:
Option 1: format()
is the simplest and most efficient
node.~format!~('{‹string1›}«delimiter»{‹string2›}')
NB. Fields in the dataset (firstname
and lastname
in this example) are referenced inside curly braces {}
. If you want to join a value of the node with user-specified text, don't surround that string with the curly braces, e.g. node.format('My name is {firstname}')
.
Option 2: join()
is more flexible because it allows you to include conditional statements and references to a node's relatives
[‹string1›,‹string2›].~join!~("«delimiter»")
Option 3: concat()
is the most long-winded
‹string1›.value.~concat!~(«delimiter»).~concat!~(‹string2›)
In SQL you have two main options for combining strings:
Option 1: +
is the quickest if you only have a few values to combine
‹field1› +' '+ ‹field2›
‹field1› +' '+ ‹string1›
Option 2: CONCAT()
is better for long chains
~CONCAT!~(‹string1›, ‹string2›«, ‹stringN»)
NB.:
CONCAT is only available with SQL2012 onwards
When concatenating, both ‹fields› (or ‹field› and ‹string›) must be of the same data type.
In Python you have two main options for combining strings:
Option 1: +
is the quickest if you only have a few values to combine
‹string1› + ‹string2›
Option 2: join()
"".~join!~(‹string1›, ‹string2›)
NB.:
To join the same string together multiple times, you can use the mathematical operator *
, e.g. ‹string1›*3 returns ‹string1string1string1›:
NB. Both arguments must be strings. To convert a different data type to a string, use ~TOSTRING!~(‹field›) or the Select tool (in the Preparation palette). Go to for more information.
The above example assumes variables have been declared for firstName
and lastName
. For more information, go to .