Tableau 简明教程

Tableau - String Calculations

在本章中,你将了解 Tableau 中涉及字符串的计算。Tableau 具有许多内置的字符串函数,可用于执行字符串操作,例如 - 比较、级联、替换字符串中的几个字符等。以下是创建计算字段并在其中使用字符串函数的步骤。

In this chapter, you will learn about calculations in Tableau involving Strings. Tableau has many inbuilt string functions, which can be used to do string manipulations such as - comparing, concatenating, replacing few characters from a string, etc. Following are the steps to create a calculation field and use string functions in it.

Create Calculated Field

连接到样例超级商店时,转到分析菜单并单击“创建计算字段”,如下面的屏幕截图所示。

While connected to Sample superstore, go to the Analysis menu and click ‘Create Calculated Field’ as shown in the following screenshot.

Create calculation

Calculation Editor

上述步骤将打开一个计算编辑器,其中列出了 Tableau 中可用的所有函数。你可以更改下拉值并仅查看与字符串相关的函数。

The above step opens a calculation editor which lists all the functions that is available in Tableau. You can change the dropdown value and see only the functions related to strings.

string calc 1

Create a Formula

请考虑你想要找出销售城市,其中包含字母“o”。为此,创建如下面的屏幕截图所示的公式。

Consider you want to find out the sales in the cities, which contain the letter “o”. For this, create the formula as shown in the following screenshot.

string calc 2

Using the Calculated Field

现在,要查看已创建字段的操作,你可以将其拖放到行搁板中并将销售字段拖放到列搁板中。下图显示了销售值。

Now, to see the created field in action, you can drag it to the Rows shelf and drag the Sales field to the Columns shelf. The following screenshot shows the Sales values.

string calc 3