Tableau Calculation string functions with Examples
Tableau has many inbuilt string functions, which allow you to manipulate string data. They are used to for comparing, concatenating and for replacing few characters from a string, etc.
Create Calculated Field
- In the Tableau Desktop, connect to the Excel file named Facebook Data which is saved in the data source.
- Navigate to the worksheet pane and click on Analysis >Create Calculated Field as shown below.
- You will notice that a new dialogue box has appeared. Click on the icon present on the rightmost side of the box.
- You can see a tab linked with the previous one which lists all the functions that are available in Tableau.
- Further, you can change the dropdown value and choose only the functions that are related to Strings.
- On the rightmost side of the pane, you will notice that Tableau is briefing us with the formula and small explanation for the selected functions.
Create the Formula
For instance, if you want to find out the sales in the direction, which has occurred particularly in “west”. For this, we will use the CONTAINS string function and will create the formula as shown in the following screenshot. Also, change the name to Direction_west. And click on OK.
In the Data pane, under Measures, you will notice a field has been created named
Direction_West.
Applying the Calculated Field
From the
Data pane, under Dimensions, drag
Month to the
Rows shelf and from Measures drag Sales to the Columns shelf. It produces a bar chart showing the number of sales held for the different regions.
The above-calculated field can be applied in the view by dragging the Direction_West field to the Filters shelf. As soon as you drag it, a pop window will open as displayed in the following screenshot.
Select the ‘True’ option and click on OK. Tableau will create the bar charts for the sales that have occurred only in West direction. The following screenshot shows the Sales values.