KNOWLEDGE BASE

Combining Two String Fields


Published: 01 May 2013
Last Modified Date: 29 May 2023

Question

How to create a calculated field that combines two string variables.

Environment

Tableau Desktop

Answer

Use the plus sign (+) operator to combine two string fields:
  1. Go to Analysis > Create Calculated Field.
  2. Name the calculated field and enter the following formula where Field1 and Field2 are string fields:
  3. [Field1] + [Field2] 
    
  4. Click OK.
  5. Drag the new calculated field to the Rows shelf to display the new string concatenation.

Additional Information

  • Using a plus sign (+) combines two string fields together ("abc"+ "def" = "abcdef").
  • If a space is needed between the two fields, modify the above formula "abc" + " " + "def"  = "abc def"
  • Any required punctuation (e.g. comma) may be added into the formula as needed.
  • Concatenating with a NULL value results in NULL. "abc" + NULL = NULL.

If you receive the error "All fields must be aggregate or constant when using table calculation functions or fields from multiple data sources." Refer to the articles below:

Unable to Use a Table Calculation such as RANK() on An LOD (Level of Detail) Calculation
Aggregate Error Messages In a Calculation Editor

 





 
Did this article resolve the issue?