String functions allow you to control string data (i.e. data made from text).
For example, you would possibly have a field that contains all of your customers’ first and last names. One member might be: Jane Johnson. you’ll pull the last names from all of your customers into a replacement field employing a string function.
Create a string calculation
Follow along side the steps below to find out the way to create a string calculation.
In Tableau Desktop, hook up with the Sample – Superstore saved data source, which comes with Tableau.
Navigate to a worksheet.
From the info pane, under Dimensions, drag Order ID to the Rows shelf.
Notice that each order ID contains values for country (CA and US, for example), year (2011), and order number (100006). For this instance , you’ll create a calculation to tug only the order number from the sector .
Select Analysis > Create Calculated Field.
In the calculation editor that opens, do the following:
Name the calculated field Order ID Numbers.
Enter the subsequent formula:
This formula takes the required digits (6) from the proper of the string and pulls them into a replacement field.
Therefore, RIGHT(‘CA-2011-100006’ , 6) = ‘100006’.
When finished, click OK.
The new calculated field appears under Dimensions within the Data pane. a bit like your other fields, you’ll use it in one or more visualizations.
From the info pane, drag Order ID Numbers to the Rows shelf. Place it to the proper of Order ID.
Notice how the fields differ now.