Tableau 简明教程

Tableau - Quick Guide

Tableau - Overview

Tableau 作为领先的数据可视化工具,拥有许多令人向往和独一无二的功能。其强大的数据发现和浏览应用程序让您可以在几秒钟内回答重要问题。您可以使用 Tableau 的拖放界面来可视化任何数据、浏览不同的视图,甚至轻松地组合多个数据库。它不需要任何复杂的脚本。任何了解业务问题的人都可以通过相关数据的可视化效果来解决问题。分析之后,只需发布到 Tableau Server 即可轻松与他人分享。

As a leading data visualization tool, Tableau has many desirable and unique features. Its powerful data discovery and exploration application allows you to answer important questions in seconds. You can use Tableau’s drag and drop interface to visualize any data, explore different views, and even combine multiple databases easily. It does not require any complex scripting. Anyone who understands the business problems can address it with a visualization of the relevant data. After analysis, sharing with others is as easy as publishing to Tableau Server.

Tableau Features

Tableau 为各种行业、部门和数据环境提供解决方案。以下是让 Tableau 能够处理各种场景的一些独一无二的功能。

Tableau provides solutions for all kinds of industries, departments, and data environments. Following are some unique features which enable Tableau to handle diverse scenarios.

  1. Speed of Analysis − As it does not require high level of programming expertise, any user with access to data can start using it to derive value from the data.

  2. Self-Reliant − Tableau does not need a complex software setup. The desktop version which is used by most users is easily installed and contains all the features needed to start and complete data analysis.

  3. Visual Discovery − The user explores and analyzes the data by using visual tools like colors, trend lines, charts, and graphs. There is very little script to be written as nearly everything is done by drag and drop.

  4. Blend Diverse Data Sets − Tableau allows you to blend different relational, semistructured and raw data sources in real time, without expensive up-front integration costs. The users don’t need to know the details of how data is stored.

  5. Architecture Agnostic − Tableau works in all kinds of devices where data flows. Hence, the user need not worry about specific hardware or software requirements to use Tableau.

  6. Real-Time Collaboration − Tableau can filter, sort, and discuss data on the fly and embed a live dashboard in portals like SharePoint site or Salesforce. You can save your view of data and allow colleagues to subscribe to your interactive dashboards so they see the very latest data just by refreshing their web browser.

  7. Centralized Data − Tableau server provides a centralized location to manage all of the organization’s published data sources. You can delete, change permissions, add tags, and manage schedules in one convenient location. It’s easy to schedule extract refreshes and manage them in the data server. Administrators can centrally define a schedule for extracts on the server for both incremental and full refreshes.

Tableau - Environment Setup

在本章节中,您将了解 Tableau 的环境设置。

In this chapter, you will learn about the environment setup of Tableau.

Download Tableau Desktop

Tableau Desktop 的免费个人版可从 Tableau Desktop. 下载。您需要使用您的详细资料进行注册才能下载。

The Free Personal Edition of Tableau Desktop can be downloaded from Tableau Desktop. You need to register with your details to be able to download.

下载后,安装过程非常简单,您需要接受许可协议并提供安装目标文件夹。以下步骤和屏幕截图描述了整个安装过程。

After downloading, the installation is a very straightforward process in which you need to accept the license agreement and provide the target folder for installation. The following steps and screenshots describe the entire setup process.

Start the Installation Wizard

双击 TableauDesktop-64bit-9-2-2.exe 。它将显示一个允许安装程序运行的屏幕。单击“运行”。

Double-click the TableauDesktop-64bit-9-2-2.exe. It will present a screen to allow the installation program to run. Click “Run”.

installation 1

Accept the License Agreement

阅读许可协议,如果您同意,请选择“我已阅读并接受该许可协议的条款”选项。然后,单击“安装”。

Read the license agreement and if you agree, choose the "I have read and accept the terms of this license agreement" option. Then, click "Install".

installation 2

Start Trial

在安装完成后,屏幕将提示您选择立即开始还是稍后开始试用。您现在可以选择开始。此外,如果您已经购买了 Tableau,那么您可以输入许可证密钥。

On completion of the installation, the screen prompts you with the option to Start the trial now or later. You may choose to start it now. Also, if you have purchased Tableau then you may enter the License key.

installation 3

Provide Your Details

提供姓名和组织详情。然后,单击“下一步”。

Provide your name and organization details. Then, click "Next".

installation 4

Registration Complete

注册完成屏幕出现。单击“继续”。

The registration completion screen appears. Click "Continue".

installation 5

Verify the Installation

您可以通过转到 Windows 开始菜单来验证安装。单击 Tableau 图标。将出现以下屏幕。

You can verify the installation by going to the Windows start menu. Click the Tableau icon. The following screen appears.

installation 6

您现在可以了解 Tableau。

You are now ready to learn Tableau.

Tableau - Get Started

在本章中,你将学习 Tableau 中的一些基本操作以熟悉其界面。创建任何 Tableau 数据分析报表涉及三个基本步骤。

In this chapter, you will learn some basic operations in Tableau to get acquainted with its interface. There are three basic steps involved in creating any Tableau data analysis report.

这三个步骤分别是−

These three steps are −

  1. Connect to a data source − It involves locating the data and using an appropriate type of connection to read the data.

  2. Choose dimensions and measures − This involves selecting the required columns from the source data for analysis.

  3. Apply visualization technique − This involves applying required visualization methods, such as a specific chart or graph type to the data being analyzed.

为方便起见,我们使用 Tableau 安装附带的示例数据集,名为 sample - superstore.xls。找到 Tableau 的安装文件夹并转至 My Tableau Repository 。在其下面,你在 Datasources\9.2\en_US-US 处将找到上述文件。

For convenience, let’s use the sample data set that comes with Tableau installation named sample – superstore.xls. Locate the installation folder of Tableau and go to My Tableau Repository. Under it, you will find the above file at Datasources\9.2\en_US-US.

Connect to a Data Source

在打开 Tableau 时,你将获得显示各种数据源的启动页。在标题 “Connect” 下,你可以选择文件、服务器或已保存的数据源。在“文件”下,选择 excel。然后导航到如上所述的文件 “Sample – Superstore.xls” 。excel 文件中有三个工作表,名为“订单”、“人员”和“退货”。选择 Orders

On opening Tableau, you will get the start page showing various data sources. Under the header “Connect”, you have options to choose a file or server or saved data source. Under Files, choose excel. Then navigate to the file “Sample – Superstore.xls” as mentioned above. The excel file has three sheets named Orders, People and Returns. Choose Orders.

1 connect ds

Choose the Dimensions and Measures

接下来,根据维度和度量选择需要分析的数据。维度是描述性数据,而度量是数字数据。将两者放在一起时,它们有助于可视化维度数据的性能与度量数据的性能。选择 CategoryRegion 作为维度,选择 Sales 作为度量。将它们拖放至以下屏幕截图中所示的位置。结果显示了每个地区在每个类别中的总销售额。

Next, choose the data to be analyzed by deciding on the dimensions and measures. Dimensions are the descriptive data while measures are numeric data. When put together, they help visualize the performance of the dimensional data with respect to the data which are measures. Choose Category and Region as the dimensions and Sales as the measure. Drag and drop them as shown in the following screenshot. The result shows the total sales in each category for each region.

2 analyse data

Apply Visualization Technique

在上一步中,您会看到这些数据仅以数字形式提供。您必须阅读和计算每一个值来判断性能。但是,您可以将它们作为图形或带有不同颜色的图表来查看,以更快速地做出判断。

In the previous step, you can see that the data is available only as numbers. You have to read and calculate each of the values to judge the performance. However, you can see them as graphs or charts with different colors to make a quicker judgment.

我们将 Marks 选项卡中的 sum(sales)列拖放到 Columns 区域中。现在,显示销售数字值的表格将自动变成条形图。

We drag and drop the sum (sales) column from the Marks tab to the Columns shelf. The table showing the numeric values of sales now turns into a bar chart automatically.

3 analyse data

您可以应用一项技术,即向现有数据添加另一个维度。这会给现有条形图添加更多颜色,如下图所示。

You can apply a technique of adding another dimension to the existing data. This will add more colors to the existing bar chart as shown in the following screenshot.

4 analyse data

Tableau - Navigation

在本章中,您将熟悉 Tableau 界面提供的各种导航功能。在运行 Tableau 桌面时,您将获得显示我们可以导航的所有命令的顶部菜单。让我们打开一个空白工作簿,并逐一了解每个菜单下的各种重要功能。

In this chapter, you will get acquainted with various navigational features available in Tableau interface. On running Tableau desktop, you get the menu at the top which shows all the commands we can navigate. Let’s open a blank workbook and go through the various important features under each menu.

Menu Commands

单击"获取开始"窗口时,您将获得包含所有可用菜单命令的主界面。它们代表 Tableau 中可用的整个功能集。以下图片中显示了菜单的各个部分。接下来,您还可以看到每个菜单的一些详细信息。

On closing the getting started window, you get the main interface with all the available Menu commands. They represent the entire set of features available in Tableau. Various sections of the menu are shown in the following diagram. Next, you can see some details of each menu.

main window

File Menu

此菜单用于创建一个新的 Tableau 工作簿,并从本地系统和 Tableau 服务器中打开现有的工作簿。此菜单中的重要功能包括:

This menu is used to create a new Tableau workbook and open existing workbooks from both the local system and Tableau server. The important features in this menu are −

  1. Workbook Locale sets the language to be used in the report.

  2. Paste Sheets pastes a sheet into the current workbook, which is copied from another workbook.

  3. Export Packaged Workbook option is used to create a packaged workbook, which will be shared with other users.

1 File menu

Data Menu

此菜单用于创建新的数据源以为分析和可视化获取数据。它还允许您替换或升级现有的数据源。

This menu is used to create new data source to fetch the data for analysis and visualization. It also allows you to replace or upgrade the existing data source.

此菜单中的重要功能包括:

The important features in this menu are as follows −

  1. New Data Source allows to view all the types of connections available and choose from it.

  2. Refresh All Extracts refreshes the data from the source.

  3. Edit Relationships option defines the fields in more than one data source for linking.

2 Data menu

Worksheet Menu

此菜单用于创建新的工作表,包含各种显示功能,如显示标题、标题等。

This menu is used to create a new worksheet along with various display features such as showing the title and captions, etc.

此菜单中的重要功能包括:

The important features in this menu are as follows −

  1. Show Summary allows to view the summary of the data used in the worksheet such as, count, etc.

  2. Tooltip shows the tooltip when hovering above various data fields.

  3. Run Update option updates the worksheet data or filters used.

3 worksheet menu

Dashboard Menu

此菜单用于创建新的仪表盘,包含各种显示功能,如显示标题、导出图像等。

This menu is used to create a new dashboard along with various display features, such as showing the title and exporting the image, etc.

此菜单中的重要功能包括:

The important features in this menu are as follows −

  1. Format sets the layout in terms of colors and sections of the dashboard.

  2. Actions link the dashboard sheets to external URLs or other sheets.

  3. Export Image option exports an image of the Dashboard.

4 dashboard menu

Story Menu

此菜单用于创建新的 story,该 story 具有许多具有关联数据 sheet 或仪表板。

This menu is used to create a new story which has many sheets or dashboards with related data.

此菜单中的重要功能包括:

The important features in this menu are as follows −

  1. Format sets the layout in terms of colors and sections of the story.

  2. Run Update updates the story with the latest data from the source.

  3. Export Image option exports an image of the story.

5 story menu

Analysis Menu

此菜单用于分析 sheet 中显示的数据。Tableau 提供许多开箱即用的功能,例如计算百分比和执行预测等。

This menu is used for analyzing the data present in the sheet. Tableau provides many outof-the-box features, such as calculating the percentage and performing a forecast, etc.

此菜单中的重要功能包括:

The important features in this menu are as follows −

  1. Forecast shows a forecast based on available data.

  2. Trend Lines shows the trend line for a series of data.

  3. Create Calculated Field option creates additional fields based on certain calculation on the existing fields.

6 analysis menu

Map Menu

此菜单用于在 Tableau 中构建地图视图。您可以为数据中的字段分配地理角色。

This menu is used for building map views in Tableau. You can assign geographic roles to fields in your data.

此菜单中的重要功能包括:

The important features in this menu are as follows −

  1. Map Layers hides and shows map layers, such as street names, country borders, and adds data layers.

  2. Geocoding creates new geographic roles and assigns them to the geographic fields in your data.

7 map menu

Format Menu

此菜单用于应用各种格式设置选项,以增强所创建仪表板的外观。它提供了边框、色彩、文本对齐等功能。

This menu is used for applying the various formatting options to enhance the look and feel of the dashboards created. It provides features such as borders, colors, alignment of text, etc.

此菜单中的重要功能包括:

The important features in this menu are as follows −

  1. Borders applies borders to the fields displayed in the report.

  2. Title & Caption assigns a title and caption to the reports.

  3. Cell Size customizes the size of the cells displaying the data.

  4. Workbook Theme applies a theme to the entire workbook.

8 format menu

Server Menu

服务器菜单用于在你拥有权限时登录 Tableau 服务器,并发布结果以供其他人使用。它还可以用来访问其他人发布的工作簿。

Server Menu is used to login to the Tableau server if you have access, and publish your results to be used by others. It is also used to access the workbooks published by others.

此菜单中的重要功能包括:

The important features in this menu are as follows −

  1. Publish Workbook publishes the workbook in the server to be used by others.

  2. Publish Data Source publishes the source data used in the workbook.

  3. Create User Filters creates filters on the worksheet to be applied by various users while accessing the report.

9 server menu

Tableau - Design Flow

由于 Tableau 有助于分析大量数据(跨越不同的时间段、维度和度量),因此需要非常精心的规划才能创建良好的仪表板或故事。因此,了解设计良好仪表板的方法非常重要。与人类努力的任何其他领域一样,要创建良好工作表和仪表板,需要遵循许多最佳实践。

As Tableau helps in analyzing lots of data over diverse time periods, dimensions, and measures, it needs a very meticulous planning to create a good dashboard or story. Hence, it is important to know the approach to design a good dashboard. Like any other field of human endeavor, there are many best practices to be followed to create good worksheets and dashboards.

虽然 Tableau 项目的最终预期结果理想情况下是带有故事的仪表板,但在达成此目标之前有许多中间步骤需要完成。以下是设计步骤的流程图,应理想地遵循该流程图以创建有效的仪表板。

Though the final outcome expected from a Tableau project is ideally a dashboard with story, there are many intermediate steps which needs to be completed to reach this goal. Following is a flow diagram of design steps that should be ideally followed to create effective dashboards.

designflow

Connect to Data Source

Tableau 可连接到所有流行的数据源。它具有内置连接器,可在提供连接参数后负责建立连接。无论它是什么,是简单的文本文件、关系源、SQL 源还是云数据库,Tableau 几乎可连接到所有数据源。

Tableau connects to all popular data sources. It has inbuilt connectors which take care of establishing the connection, once the connection parameters are supplied. Be it simple text files, relational sources, SQL sources or cloud data bases, Tableau connects to nearly every data source.

Build Data Views

连接到数据源后,您会获得 Tableau 环境中提供的所有列和数据。您可以将它们归类为维度和度量,并创建所需的任何层次结构。使用它们,您可以构建视图,这些视图传统上称为报告。Tableau 提供简单的拖放功能来构建视图。

After connecting to a data source, you get all the column and data available in the Tableau environment. You classify them as dimensions and measures, and create any hierarchy required. Using these you build views, which are traditionally known as Reports. Tableau provides easy drag and drop feature to build views.

Enhance the Views

需要通过使用筛选器、聚合、轴标记、颜色和边框格式等方式进一步增强创建的视图。

The views created above needs to be enhanced further by the use of filters, aggregations, labeling of axes, formatting of colors and borders, etc.

Create Worksheets

创建不同的工作表以创建相同或不同数据上的不同视图。

Create different worksheets to create different views on the same or different data.

Create and Organize Dashboards

仪表板包含多个链接的工作表。因此,任何工作表中的操作都可以相应地更改仪表板中的结果。

Dashboards contain multiple worksheets which are linked. Hence, the action in any of the worksheet can change the result in the dashboard accordingly.

Create a Story

故事是一张包含一系列的工作表或仪表板的表格,它们共同协作以传达信息。您可以创建故事来展示事实如何联系起来,提供背景,演示决策与结果的关系,或者简单地提出一个令人信服的理由。

A story is a sheet that contains a sequence of worksheets or dashboards that work together to convey information. You can create stories to show how facts are connected, provide context, demonstrate how decisions relate to outcomes, or simply make a compelling case.

Tableau - File Types

Tableau 中的数据分析结果可以保存为各种格式,以便保存和分发。不同的格式被称为不同的文件类型,它们通过不同的扩展名来识别。它们的格式取决于它们如何生成以及用于什么目的。它们全都存储为 XML 文件,可以打开和编辑。

The result of data analysis in Tableau can be saved in various formats, to be saved and distributed. The various formats are referred as different file types and they are identified by different extensions. Their formats depend on how they are produced and for what purposes they are used. They are all stored as XML files, which can be opened and edited.

下表列出了每种文件类型的说明及其用法。

Following table lists the description of each file type and their usage.

File Type

File Extension

Purpose

Tableau Workbook

.twb

It contains information on each sheet and dashboard that is present in a workbook. It has the details of the fields, which are used in each view and the formula applied to the aggregation of the measures. It also has the formatting and styles applied. It contains the data source connection information and any metadata information created for that connection.

Tableau Packaged Workbook

.twbx

This file format contains the details of a workbook as well as the local data that is used in the analysis. Its purpose is to share with other Tableau desktop or Tableau reader users, assuming it does not need data from the server.

Tableau Data Source

.tds

The details of the connection used to create the tableau report are stored in this file. In the connection details, it stores the source type (excel/relational/sap, etc.) as well as the data types of the columns.

Tableau Packaged Data source

.tdsx

This file is similar to the .tds file with the addition of data along with the connection details.

Tableau Data Extract

.tde

This file contains the data used in a .twb file in a highly compressed columnar data format. This helps in storage optimization. It also saves the aggregated calculations that are applied in the analysis. This file should be refreshed to get the updated data from the source.

Tableau Bookmark

.tbm

These files contain a single worksheet that is shared easily to be pasted into other workbooks.

Tableau Preferences

.tps

This file stores the color preference used across all the workbooks. It is mainly used for consistent look and feel across the users.

Tableau - Data Types

作为数据分析工具,Tableau 将每条数据分类到四个类别之一,即字符串、数字、布尔值和日期时间。从源加载数据后,Tableau 会自动分配数据类型。相反,如果符合数据转换规则,您也可以更改一些数据类型。用户必须为计算字段指定数据类型。

As a data analysis tool, Tableau classifies every piece of data into one of the four categories namely - String, Number, Boolean and datetime. Once data is loaded from the source, Tableau automatically assigns the data types. Contrarily, you can also change some of the data types if it satisfies the data conversion rule. The user has to specify the data type for calculated fields.

下表列出了 Tableau 支持的数据类型的描述。

Following table lists the description of data types supported by Tableau.

Data Type

Description

Example

STRING

Any sequence of zero or more characters. They are enclosed within single quotes. The quote itself can be included in a string by writing it twice.

'Hello' 'Quoted' 'quote'

NUMBER

These are either integers or floating points. It is advised to round the floating point numbers while using them in calculations.

3 142.58

BOOLEAN

They are logical values.

TRUE FALSE

DATE & DATETIME

Tableau recognizes dates in almost all formats. But in case we need to force Tableau to recognize a string as date, then we put a # sign before the data.

"02/01/2015" "#3 March 1982"

Tableau - Show Me

作为一种高级数据可视化工具,Tableau 不需要编写任何自定义代码,就可以通过提供许多分析技术让数据分析变得非常容易。Show Me 就是此类功能之一。它可以用于将必需的视图应用于工作表中的现有数据。这些视图可以是饼图、散点图或折线图。

As an advanced data visualization tool, Tableau makes the data analysis very easy by providing many analysis techniques without writing any custom code. One such feature is Show Me. It can be used to apply a required view to the existing data in the worksheet. Those views can be a pie chart, scatter plot, or a line chart.

每当创建包含数据的工作表时,它都可用在右上角,如下面图片所示。一些视图选项将根据数据窗格中选择的性质而变灰。

Whenever a worksheet with data is created, it is available in the top right corner as shown in the following figure. Some of the view options will be greyed out depending on the nature of selection in the data pane.

show me 1

Show Me with Two Fields

您可以使用 Show Me 中提供的各种图形和图表轻松地目视分析两个字段之间的关系。在本例中,我们选择两个字段并应用折线图。以下为步骤:

The relation between two fields can be visually analyzed easily by using various graphs and charts available in Show Me. In this case, we choose two fields and apply a line chart. Following are the steps −

  1. Step 1 − Select the two fields (order date and profit) to be analyzed by holding the control key.

  2. Step 2 − Click the Show Me bar and choose line chart.

  3. Step 3 − Click the Mark Label button on the scrollbar.

以下图表展示使用上述步骤创建的折线图。

The following diagram shows the line chart created using the above steps.

show me 2

Show Me with Multiple Fields

我们可以应用与上述类似的技术来分析多于 2 个字段。本例中的唯一差别在于活动形式中可用的视图较少。Tableau 会自动将不适合所选字段分析的视图变灰。

We can apply a similar technique as above to analyze more than 2 fields. The only difference in this case will be the availability of fewer views in active form. Tableau automatically greys out the views that are not appropriate for the analysis of the fields chosen.

此例中,按住 Control 键选择字段的产品名称、客户姓名、销售额和利润。正如您所观察到的那样,Show Me 中大多数视图都显示为灰色。从活动视图中选择散点视图。

In this case, choose the field’s product name, customer name, sales and profit by holding down the control key. As you can observe, most of the views in Show Me are greyed out. From the active views, choose Scatter View.

下图显示了创建的散点视图图表。

The following diagram shows the Scatter View chart created.

show me 3

Tableau - Data Terminology

作为一款强大的数据可视化工具,Tableau 具有许多独特的术语和定义。在开始使用 Tableau 中的功能之前,您需要熟悉它们各自的含义。下面的术语列表比较全面,并且解释了最常用的术语。

As a powerful data visualization tool, Tableau has many unique terms and definitions. You need to get acquainted with their meaning before you start using the features in Tableau. The following list of terms is comprehensive and explains the terms most frequently used.

S.No

Terms & Meaning

1

Alias An alternative name that you can assign to a field or to a dimension member.

2

Bin A user-defined grouping of measures in the data source.

3

Bookmark A .tbm file in the Bookmarks folder in the Tableau repository that contains a single worksheet. Much like web browser bookmarks, .tbm files are a convenient way to quickly display different analyses.

4

Calculated Field A new field that you create by using a formula to modify the existing fields in your data source.

5

Crosstab A text table view. Use text tables to display the numbers associated with dimension members.

6

Dashboard A combination of several views arranged on a single page. Use dashboards to compare and monitor a variety of data simultaneously.

7

Data Pane A pane on the left side of the workbook that displays the fields of the data sources to which Tableau is connected. The fields are divided into dimensions and measures. The data pane also displays custom fields such as calculations, binned fields, and groups. You build views of your data by dragging fields from the data pane onto the various shelves that are a part of every worksheet.

8

Data Source Page A page where you can set up your data source. The data source page generally consists of four main areas − left pane, join area, preview area, and metadata area.

9

Dimension A field of categorical data. Dimensions typically hold discrete data such as hierarchies and members that cannot be aggregated. Examples of dimensions include dates, customer names, and customer segments.

10

Extract A saved subset of a data source that you can use to improve performance and analyze offline. You can create an extract by defining filters and limits that include the data you want in the extract.

11

Filters Shelf A shelf on the left of the workbook that you can use to exclude data from a view by filtering it using measures and dimensions.

12

Format Pane A pane that contains formatting settings that control the entire worksheet, as well as individual fields in the view. When open, the Format pane appears on the left side of the workbook.

13

Level Of Detail (LOD) Expression A syntax that supports aggregation at dimensionalities other than the view level. With the level of detail expressions, you can attach one or more dimensions to any aggregate expression.

14

Marks A part of the view that visually represents one or more rows in a data source. A mark can be, for example, a bar, line, or square. You can control the type, color, and size of marks.

15

Marks Card A card to the left of the view, where you can drag fields to control mark properties such as type, color, size, shape, label, tooltip, and detail.

16

Pages Shelf A shelf to the left of the view that you can use to split a view into a sequence of pages based on the members and values in a discrete or continuous field. Adding a field to the Pages shelf is like adding a field to the Rows shelf, except that a new page is created for each new row.

17

Rows Shelf A shelf at the top of the workbook that you can use to create the rows of a data table. The shelf accepts any number of dimensions and measures. When you place a dimension on the Rows shelf, Tableau creates headers for the members of that dimension. When you place a measure on the Rows shelf, Tableau creates quantitative axes for that measure.

18

Shelves Named areas to the left and top of the view. You build views by placing fields onto the shelves. Some shelves are available only when you select certain mark types. For example, the Shape shelf is available only when you select the Shape mark type.

19

Workbook A file with a .twb extension that contains one or more worksheets (and possibly also dashboards and stories).

20

Worksheet A sheet where you build views of your data by dragging fields onto shelves.

Tableau - Data Sources

Tableau 可以连接到广泛使用的所有流行数据源。Tableau 的本机连接器可以连接到以下类型的数据源。

Tableau can connect to all the popular data sources which are widely used. Tableau’s native connectors can connect to the following types of data sources.

  1. File Systems such as CSV, Excel, etc.

  2. Relational Systems such as Oracle, Sql Server, DB2, etc.

  3. Cloud Systems such as Windows Azure, Google BigQuery, etc.

  4. Other Sources using ODBC

下图显示了 Tableau 的本机数据连接器可提供的多数数据源。

The following picture shows most of the data sources available through Tableau’s native data connectors.

data source 1

Connect Live

实时数据连接功能用于实时数据分析。在这种情况下,Tableau 会连接到实时数据源并不断读取数据。因此,分析结果是最新的,并且最新的更改会反映在结果中。但是,缺点是它会增加源系统负担,因为源系统必须不断向 Tableau 发送数据。

The Connect Live feature is used for real-time data analysis. In this case, Tableau connects to real-time data source and keeps reading the data. Thus, the result of the analysis is up to the second, and the latest changes are reflected in the result. However, on the downside, it burdens the source system as it has to keep sending the data to Tableau.

In-Memory

Tableau 还可以通过将数据缓存到内存中并不再连接到源来处理内存中的数据,同时分析数据。当然,缓存的数据量会有限制,取决于可用内存。

Tableau can also process data in-memory by caching them in memory and not being connected to the source anymore while analyzing the data. Of course, there will be a limit to the amount of data cached depending on the availability of memory.

Combine Data Sources

Tableau 可以同时连接到不同的数据源。例如,在单个工作簿中,您可以通过定义多个连接来连接到平面文件和关系源。这可用于数据混合,这是 Tableau 中一项非常独特的功能。

Tableau can connect to different data sources at the same time. For example, in a single workbook you can connect to a flat file and a relational source by defining multiple connections. This is used in data blending, which is a very unique feature in Tableau.

Tableau - Custom Data View

自定义数据视图用于扩展常规数据视图,并提供一些附加功能,以便视图可以针对相同的基础数据给出不同类型的图表。例如,您可以深入挖掘维度字段,这是预定义层次结构的一部分,以便获得以不同粒度获得的度量附加值。以下是 Tableau 提供的一些常用的重要自定义数据视图。

A custom data view is used to extend the normal data views with some additional features so that the view can give different types of charts for the same underlying data. For example, you can drill down a dimension field which is part of a pre-defined hierarchy so that additional values of the measures are obtained at a different granularity. Following are some of the frequently used and important custom data views Tableau offers.

Drill Down View

用于层次结构的维度字段,您通常需要了解聚合的下一个或上一个级别的分析结果。例如,当您了解到季度结果时,您就会对该季度内每个月的结果感兴趣,您可能还需要了解每周的结果。这是深入挖掘现有维度以获得更精细粒度级别的一个用例。

For dimension fields which are part of a hierarchy, you usually need to know the result of analysis for the next or previous level of aggregation. For example, when you know the result for a quarter, you get interested to know the results for each month in that quarter, and you may even need the result for each week. This is a case of drilling down the existing dimensions to get a finer level of granularity.

要在层次结构中深入挖掘和深入挖掘各个维度成员,请右键单击表格标题,然后从上下文菜单中选择深入挖掘。考虑使用“列”选区中的维度类别和“行”选区中的度量销售额创建的条形图。右键单击代表家具的条形,然后选择深入挖掘。

To drill down and drill up for individual dimension members in a hierarchy, right-click a table header and select Drill Down from the context menu. Consider a bar chart created with the dimension category in the columns shelf and the measure Sales in the Rows shelf. Right-click on the bar representing Furniture and select Drill Down.

custom data view 1

深入挖掘操作的结果显示在以下屏幕截图中。

The result of the drill down action is shown in the following screenshot.

custom data view 2

Swapping Dimensions

您可以通过交换维度的位置从现有视图创建新视图。这不会更改度量的值,但会更改度量的值的位置。考虑一个视图,用于分析每个产品细分和类别的每年的利润。您可以单击类别列末尾的竖线,然后将其拖动到细分列。此操作显示在以下屏幕截图中。

You can create a new view from an existing view by swapping the position of the dimensions. This does not change the values of the measures, but it does change the position of the measures. Consider a view for analyzing the Profit for each year for each segment and category of products. You can click on the vertical line at the end of category column and drag it to the segment column. This action is shown in the following screenshot.

custom data view 4

交换这两个维度的结果显示在以下屏幕截图中。如您所见,只有每个类别和细分的度量利润的值的位置发生变化,而不是其值。

The result of the swapping of the two dimensions is shown in the following screenshot. As you can see, only the position of the values of the measure Profit changes for each category and segment, and not its value.

custom data view 5

Tableau - Extracting Data

Tableau 中的数据提取从数据源中创建数据子集。这通过应用筛选器来提高性能很有用。它还有助于将 Tableau 的一些功能应用于数据,而这些功能可能在数据源中不可用,例如查找数据中的不同值。但是,数据提取功能最常用于创建要存储在本地驱动器中的提取,以便 Tableau 可脱机访问。

Data extraction in Tableau creates a subset of data from the data source. This is useful in increasing the performance by applying filters. It also helps in applying some features of Tableau to data which may not be available in the data source like finding the distinct values in the data. However, the data extract feature is most frequently used for creating an extract to be stored in the local drive for offline access by Tableau.

Creating an Extract

通过菜单“数据 → 提取数据”完成数据提取。它会创建许多选项,例如对要提取的行数应用限制以及是否要聚合维度数据。以下屏幕显示了“提取数据”选项。

Extraction of data is done by following the menu - Data → Extract Data. It creates many options such as applying limits to how many rows to be extracted and whether to aggregate data for dimensions. The following screen shows the Extract Data option.

extract data 1

Applying Extract Filters

要从数据源中提取数据子集,您可以创建筛选器,这些筛选器将仅返回相关行。让我们考虑 Sample Superstore 数据集并创建提取。在筛选器选项中,选择“从列表中选择”,然后选中要从源中提取数据所需复选框值。

To extract a subset of data from the data source, you can create filters which will return only the relevant rows. Let’s consider the Sample Superstore data set and create an extract. In the filter option, choose Select from list and tick mark the checkbox value for which you need to pull the data from the source.

extract data 2

Adding New Data to Extract

要为已创建的提取添加更多数据,可以选择选项“数据 → 提取 → 从文件中附加数据”。在此情况下,浏览包含数据的文件,然后单击“确定”以完成。当然,文件中的列数量和数据类型应与现有数据同步。

To add more data for an already created extract, you can choose the option Data → Extract → Append Data from File. In this case, browse the file containing the data and click OK to finish. Of course, the number and datatype of columns in the file should be in sync with the existing data.

extract data 5 incremental

Extract History

您可以验证数据提取历史记录,以确保了解提取发生了多少次以及在什么时间。

You can verify the history of data extracts to be sure about how many times the extract has happened and at what times.

为此,您可以使用菜单“数据 → 提取历史记录”。

For this, you can use the menu - Data → Extract History.

extract data 4

Tableau - Fields Operations

Tableau 有许多功能可用于操纵 Tableau 数据窗格中显示的字段。您可以重命名字段或合并两个字段以创建单个字段。此类操作有助于更好地组织维度和度量,以及针对两个或多个同名字段执行更好的数据分析。

Tableau has many features to manipulate the fields present in Tableau data pane. You can rename the fields or combine two fields to create one field. Such operations help in better organization of the dimensions and measures, as well as accommodate two or more fields with the same name for better data analysis.

以下是此类字段操作的一些重要示例。

Following are the important examples of such Field Operations.

Adding Fields to Worksheet

您可以通过右键单击并选择添加到工作表的选项向工作表添加任意字段。您还可以将字段拖放到工作表中存在的不同容器中,例如“列”容器、“行”容器、“筛选器”容器以及标记卡下的许多其他容器。下图显示了右键单击选项。

You can add any field to the worksheet by right-clicking and choosing the option Add to Sheet. You can also drag and drop the fields into different shelves present in the worksheet, like Columns shelf, Rows shelf, Filters shelf, and many other shelves under the Marks card. The following diagram shows the right-click option.

Field operation 1

Combining Two Fields

您可以合并两个维度字段来创建一个字段。此合并字段有一个名称,它是由各个字段组合而成的。维度中的值通过将两个字符串组合成一个字符串(用逗号分隔)来组合成一个值。但是,可以通过使用重命名字段操作来更改此默认名称。下图显示了合并两个字段的步骤。

You can combine two dimension fields to create one field. This combined field has a name which is a combination of the individual fields. The values in the dimension get combined to a single value by joining the two strings into one string separated by a comma. However, this default name can be changed by using the rename field operation. The following diagram shows the step to combine two fields.

Field operation 2

Searching Fields

您可以使用搜索框选项搜索字段的名称。编写字段名称的前三个或更多个字母会显示仅显示名称中包含这些字母的字段的结果。

You can search for names of fields by using the search box option. Writing first three or more letters of the field name brings out the result showing only the fields whose name contains these letters.

Field operation 3

Reordering Fields

您可以通过简单地向上或向下拖动字段来更改字段的位置。在以下示例中,我们将字段客户姓名拖到州和城市之间的位置。通常这样做是为了将经常用于分析的相似字段组合在一起。

You can change the position of fields by simply dragging them up and down. In the following example, we drag the field customer name to the place between state and city. This is usually done to bring similar fields together which are frequently used for analysis.

Field operation 4

Tableau - Editing Metadata

连接到数据源后,Tableau 会捕获源的元数据详细信息,如列及其数据类型。这用于在视图中创建维度、度量和计算字段。可以浏览元数据并更改其中一些属性以满足某些特定要求。

After connecting to the data source, Tableau captures the metadata details of the source like the columns and their data types. This is used to create the dimensions, measures, and calculated fields used in views. You can browse the metadata and change some of its properties for some specific requirements.

Checking the Metadata

连接到数据源后,Tableau 会显示源中存在的所有可能表和列。考虑源“Sample Coffee shop”以检查元数据。单击数据菜单,然后选择连接到数据源。浏览名为“Sample - Coffee shop”的 MS access 文件。将名为 Product 的表拖到数据画布。在选择文件时,你将获得以下屏幕,其中显示列名称及其数据类型。字符串数据类型显示为 Abc ,而数字数据类型显示为 #。

After connecting to a data source, Tableau presents all possible tables and columns present in the source. Consider the source ‘Sample Coffee shop’ for checking the metadata. Click the Data menu and choose to connect to a data source. Browse for the MS access file named ‘Sample - Coffee shop’. Drag the table named Product to the data canvas. On choosing the file, you get the following screen which shows the column names, their data types. The string data types are shown as Abc and Numeric data types are shown as #.

metadata 1

Changing the Data Type

如果需要,可以更改某些字段的数据类型。根据源数据,有时 Tableau 可能无法从源识别数据类型。在这种情况,我们可以手动编辑数据类型。以下屏幕截图显示了该选项。

You can change the datatype of some of the fields if required. Depending on the nature of source data, sometimes Tableau may fail to recognize the data type from the source. In such scenarios, we can manually edit the data type. The following screenshot shows the option.

metadata 2

Renaming and Hiding

可以通过重命名选项更改列名称。还可以隐藏列,使其不会出现在创建的数据视图中。这些选项可通过单击元数据网格中的数据类型图标获得,如下面的屏幕截图所示。

The column names can be changed by using the renaming option. You can also hide a column so that it does not appear in the data view that you create. These options are available by clicking on the data type icon in the metadata grid as shown in the following screenshot.

metadata 3

Column Alias

可以为数据源的每一列指定别名,这有助于更好地理解列的性质。可以选择上述步骤中的别名选项,将会出现以下屏幕,用于创建或编辑别名。

Each column of the data source can be assigned an alias which helps better understand the nature of the column. You can choose the aliases option from the above step and the following screen comes up which is used to create or edit aliases.

metadata 4

Tableau - Data Joining

数据连接是任何数据分析中非常常见的需求。您可能需要连接来自多个来源的数据或连接单个来源中来自不同表的数据。Tableau 提供了使用数据菜单下编辑数据源中提供的“数据”窗格连接表的功能。

Data joining is a very common requirement in any data analysis. You may need to join data from multiple sources or join data from different tables in a single source. Tableau provides the feature to join the table by using the data pane available under Edit Data Source in the Data menu.

Creating a Join

考虑数据源“示例超级商店”,在“订单”和“退货”表之间创建连接。为此,请转到数据菜单并选择编辑数据源选项。接下来,将两个表(订单和退货)拖到“数据”窗格。Tableau 将根据字段名称和数据类型自动创建连接,此连接以后可以更改。

Consider the data source ‘Sample superstore’ to create a join between Orders and Returns table. For this, go to the Data menu and choose the option Edit Data Source. Next, drag the two tables, Orders and Returns to the data pane. Depending on the field name and datatype, Tableau will automatically create a join which can be changed later.

下图显示了使用字段订单 ID 创建订单和退货之间的内部连接。

The following screenshot shows the creation of an inner join between Orders and Returns using the Field Order ID.

data join 1

Editing a Join Type

表自动创建的连接类型可以手动更改。为此,请单击显示连接的两个圆圈的中间。下方出现一个弹出窗口,显示四种可用连接类型。此外,Tableau 根据数据源中存在的数据自动灰显某些类型的连接,认为这些连接无关。

The type of join which the table creates automatically can be changed manually. For this, click the middle of the two circles showing the join. A popup window appears below which shows the four types of joins available. Also Tableau automatically greys out some types of joins, which it finds irrelevant on the basis of data present in the data source.

在下图中,您可以看到内部连接和左外部连接作为可用连接。

In the following screenshot, you can see the inner and left outer join as the available joins.

data join 2

Editing Join Fields

您还可以通过单击连接弹出窗口中可用的数据源选项来更改形成连接条件的字段。在选择该字段时,您还可以使用搜索文本框搜索正在寻找的字段。

You can also change the fields forming the join condition by clicking the Data Source option available in the join popup window. While selecting the field, you can also search for the field you are looking for using a search text box.

data join 3

Tableau - Data Blending

数据混合是 Tableau 中一个非常强大的功能。当多个数据源中存在相关数据时,您希望将它们分析到单个视图中,这时就使用数据混合。例如,考虑了在关系数据库中的销售数据和 Excel 电子表格中的销售目标数据。现在,为了将实际销售额与目标销售额进行比较,您可以基于公共维度混合数据以获取 Sales Target 度量。数据混合中的两个源被称为主要数据源和辅助数据源。在主要数据源和辅助数据源之间创建左连接,其中包括主要数据源的所有数据行以及来自辅助数据源的匹配数据行。

Data Blending is a very powerful feature in Tableau. It is used when there is related data in multiple data sources, which you want to analyze together in a single view. As an example, consider the Sales data is present in a relational database and Sales Target data in an Excel spreadsheet. Now, to compare actual sales to target sales, you can blend the data based on common dimensions to get access to the Sales Target measure. The two sources involved in data blending are referred as primary and secondary data sources. A left join is created between the primary data source and the secondary data source with all the data rows from primary and matching data rows from secondary data source.

Preparing Data for Blending

Tableau 有两个内置数据源 Sample-superstoreSample coffee chain.mdb ,它们将用于说明数据混合。

Tableau has two inbuilt data sources named Sample-superstore and Sample coffee chain.mdb which will be used to illustrate data blending.

首先,将示例咖啡连锁店加载到 Tableau 并查看其元数据。转到菜单 - Data → New Data Source 并浏览示例咖啡连锁店文件,它是一个 MS Access 数据库文件。下面的屏幕截图显示了文件中提供的不同表和连接。

First load the sample coffee chain to Tableau and look at its metadata. Go to the menu - Data → New Data Source and browse for the sample coffee chain file, which is a MS Access database file. The following screenshot shows the different tables and joins available in the file.

data blend connect coffee

Adding Secondary Data Source

接下来,通过再次按照步骤 - Data → New Data Source 并选择此数据源来添加名为 Sample-superstore 的辅助数据源。这两个数据源现在会像下面的屏幕截图中所示那样显示在 Data 窗口中。

Next, add the secondary data source named Sample-superstore by again following the steps - Data → New Data Source and choosing this data source. Both the data sources now appear on the Data window as shown in the following screenshot.

data blend display coffee

Blending the Data

现在,您可以基于公共维度集成来自以上两个源的数据。请注意,在名为 State 的维度旁边会出现一个小的链条图像。这表示两个数据源之间的公共维度。将主数据源中的 State 字段拖动到 rows 货架,将次数据源中的 Profit Ratio 字段拖动到 Columns 货架。然后,从 Show Me 中选择子弹图选项以获取下面的屏幕截图中所示的子弹图。该图表显示了连锁超市和咖啡店中各个州的利润率如何变化。

Now you can integrate the data from both the above sources based on a common dimension. Note that a small chain image appears next to the dimension named State. This indicates the common dimension between the two data sources. Drag the State field from the primary data source to the rows shelf and the field Profit Ratio from the secondary data source to the Columns shelf. Then, select the bullet chart option from Show Me to get the bullet chart shown in the following screenshot. The chart shows how the profit ratio varies for each state in both the superstore and coffee chain shops.

data blend state coffe n bullet

Tableau - Add Worksheets

Tableau 屏幕中的工作表是创建数据分析视图的区域。当您建立与数据源的连接时,Tableau 默认提供三个空白工作表。您可以继续添加多个工作表,在一个屏幕中一个接一个地查看不同的数据视图。

Worksheet in the Tableau screen is the area where you create the views for data analysis. By default, Tableau provides three blank worksheets when you have established a connection to data source. You can go on adding multiple worksheets to look at different data views in the same screen, one after another.

Adding a Worksheet

您可以通过两种方式添加工作表。右键单击当前工作表的名称,然后从弹出菜单中选择新建工作表选项。您还可以单击最后一张工作表名称右侧的小图标来添加工作表。

You can add a worksheet in two ways. Right-click on the name of the current worksheet and choose the option New Worksheet from the pop-up menu. You can also click on the small icon to the right of the last sheet name to add a worksheet.

add worksheet 1

Quick Preview of a Worksheet

停留在一个工作表中,可以通过将鼠标悬停在另一个工作表的名称上来快速预览另一个工作表。

Staying in one worksheet, you can have a quick preview of another worksheet by hovering the mouse on the name of the other worksheet.

add worksheet 2

Tableau - Rename Worksheet

您可以通过重命名工作表来为现有工作表指定适当的名称。这有助于将工作表的内容与其名称联系起来。例如,如果我们想知道哪个工作表具有了解分段利润的视图,那么我们可以通过适当的工作表名称来识别它。

You can give appropriate names to the existing worksheets by renaming a worksheet. This helps in relating the content of the worksheet with its name. For example, if we want to know which sheet has the view to know the segment wise profit then with a proper name of the sheet we can identify it.

Renaming the Worksheet

要重命名工作表,请右键单击工作表名称,然后选择重命名工作表选项。

To rename a worksheet, right-click the sheet name and choose the option Rename Sheet.

rename worksheet 1

下图显示了具有新名称的工作表。

The following diagram shows the worksheet with the new name.

rename worksheet 2

Tableau - Save & Delete Worksheet

现有工作表可以同时保存和删除。这有助于整理 Tableau 桌面环境中的内容。虽然您可以通过单击主菜单下的保存按钮保存工作表,但您还可以使用以下步骤删除工作表。

An existing worksheet can be both saved and deleted. This helps in organizing the contents in the Tableau desktop environment. While you can save a worksheet by clicking the save button under the main menu, you can delete a worksheet using the following steps.

Deleting the Worksheet

要删除工作表,右键单击工作表的名称并选择选项“删除工作表”。

To delete a worksheet, right-click on name of the worksheet and choose the option ‘Delete Sheet’.

Delete worksheet

以下屏幕截图显示工作表已被删除。

The following screenshot shows the worksheet has been deleted.

Delete worksheet 2

Tableau - Reorder Worksheet

有时候,您需要更改现有工作表的位置,以便更好地研究它们。可以通过将表格名称从其现有位置拖到新位置来简单地完成此操作。

Sometimes you need to change the position of the existing worksheet to study them in a better way. This can be done in a simple way by dragging the sheet name from its existing position to the new position.

Reordering the Worksheet

要重新排列工作表,请单击并按住工作表名称,然后将其移动到所需位置。考虑以下屏幕截图中显示的三个工作表。

To reorder a worksheet, click and hold the worksheet name and move it to the desired position. Consider the three worksheets as shown in the following screenshot.

reorder worksheet

以下屏幕截图显示了在将第三个工作表从左侧拖到新位置时,在新位置上会出现一条竖直的深色线。

The following screenshot shows that a vertical dark line appears in the new position on dragging the third worksheet from left to the new position.

reorder worksheet 2

Tableau - Paged Workbook

分页工作簿用于为维度或度量的不同值在不同页面中保存数据的视图。一个常见的示例是查看每种产品类型在特定销售区域中相对于其他产品类型的表现情况。由于每种产品类型的不同值都存储在一个单独的页面中,我们可以一次查看它们或将它们视为一个值范围。

A paged workbook is used to save the view of the data in different pages for different values of the dimension or measure. A common example is to see how each type of products have performed against each other in a specific sales region. As each of the values of product type is stored as a separate page, we can view them one at a time or see it as a range of values.

Creating Paged Workbook

分页工作簿包含将字段放置在页面架上的工作表。考虑研究产品不同子类别在不同地区的利润的示例。以下为步骤。

The paged workbook contains worksheets which have fields put in the page shelf. Consider an example of studying the profit of various sub-category of products in different regions. Following are the steps.

Step 1 − 创建具有两个维度和一个度量的条形图。在此情况下,将度量“利润”拖动到列架,将维度“子类别”和“地区”拖动到行架,如下图所示。

Step 1 − Create a bar chart with two dimensions and one measure. In this case, drag the Measure Profit to the columns shelf and the dimensions sub-category, and Region to the rows shelf as shown in the following screenshot.

paged worksheet 1

Step 2 - 再次将子类别字段拖到页面栏。你将看到自动添加了一个页面控件,就在页面栏的下方。此页面控件提供以下功能,以导航视图中的页面:

Step 2 − Drag the Sub-Category field again to the page shelf. You will see that a page control is automatically added, just below the Pages shelf. This page control provides the following features to navigate through the pages in a view −

  1. Jump to a specific page

  2. Manually advance through the pages

  3. Automatically advance through pages

在此示例中,我们将了解如何跳转到特定页面以及如何获取页面的自动显示。要转到特定页面,请单击页面控件上的下拉列表,然后选择配件。出现以下屏幕截图所示的图表。

In this case, we will see how to jump to a specific page and how to get the automatic display of pages. To go to a specific page, click on the drop-down on the page control and select Accessories. The chart seen in the following screenshot appears.

paged worksheet 2

Step 3 - 对于页面的自动显示,保持显示历史记录复选框被选中,然后单击播放按钮。然后可以看到子类别的不同页面自动播放。当前子类别值显示为暗色,而前值则以浅色显示。以下屏幕截图对此进行了说明。

Step 3 − For automatic display of pages, keep the show history checkbox ticked and click the play button. You can then see an automatic play of different pages of sub categories. While the current Sub-Category value is shown with a dark color, the previous values are shaded with light color. The following screenshot illustrates this.

paged worksheet 3

Tableau - Operators

运算符是一个符号,它告诉编译器执行特定的数学或逻辑操作。Tableau 具有许多运算符,用于创建计算字段和公式。

An operator is a symbol that tells the compiler to perform specific mathematical or logical manipulations. Tableau has a number of operators used to create calculated fields and formulas.

以下是可用运算符的详细信息以及运算的顺序(优先级)。

Following are the details of the operators that are available and the order (precedence) of operations.

Types of Operator

  1. General Operators

  2. Arithmetic Operators

  3. Relational Operators

  4. Logical Operators

General Operators

下表显示了 Tableau 支持的通用运算符。这些运算符作用于数字、字符和日期数据类型。

Following table shows the general operators supported by Tableau. These operators act on numeric, character, and date data types.

Operator

Description

Example

+(addition)

Adds two numbers. Concatenates two strings. Adds days to dates.

7 + 3 Profit + Sales 'abc' + 'def' = 'abcdef' April 15, 2004 + 15 = April 30, 2004

–(subtraction)

Subtracts two numbers. Subtracts days from dates.

-(7+3) = -10 April 16, 2004 - 15 = April 1, 2004

Arithmetic Operators

下表显示了 Tableau 支持的算术运算符。这些运算符仅对数字数据类型起作用。

Following table shows the arithmetic operators supported by Tableau. These operators act only on numeric data types.

Operator

Description

Example

*(Multiplication)

Numeric multiplication

23*2 = 46

/(Division)

Numeric division

45/2 = 22.5

%(modulo)

Reminder of numeric division

13 % 2 = 1

^(power)

Raised to the power

2^3 = 8

Comparison Operators

下表列出了 Tableau 支持的比较运算符。这些运算符用于表达式中。每个运算符将比较两个数字、日期或字符串,并返回布尔值(真或假)。然而,布尔值本身无法使用这些运算符比较。

Following table lists the comparison operators supported by Tableau. These operators are used in expressions. Each operator compares two numbers, dates, or strings and returns a Boolean (TRUE or FALSE). Booleans themselves, however, cannot be compared using these operators.

Operator

Description

Example

= = or = (Equal to)

Compares two numbers or two strings or two dates to be equal. Returns the Boolean value TRUE if they are, else returns false.

‘Hello’ = ‘Hello’ 5 = 15/ 3

!= or <> (Not equal to)

Compares two numbers or two strings or two dates to be unequal. Returns the Boolean value TRUE if they are, else returns false.

‘Good’ <> ‘Bad’ 18 != 37 / 2

> (Greater than)

Compares two numbers or two strings or two dates where the first argument is greater than second. Returns the boolean value TRUE if it is the case, else returns false.

[Profit] > 20000 [Category] > ‘Q’ [Ship date] > April 1, 2004

< (Less than)

Compares two numbers or two strings or two dates where the first argument is smaller than second. Returns the boolean value TRUE if it is the case, else returns false.

[Profit] < 20000 [Category] < ‘Q’ [Ship date] < April 1, 2004

Logical Operators

下表显示了 Tableau 支持的逻辑运算符。这些运算符用于表达式中,该表达式的结果为布尔值,输出为真或假。

Following table shows the logical operators supported by Tableau. These operators are used in expressions whose result is a Boolean giving the output as TRUE or FALSE.

Operator

Description

Example

AND

If the expressions or Boolean values present on both sides of AND operator is evaluated to be TRUE, then the result is TRUE. Else the result is FALSE.

[Ship Date] > April 1, 2012 AND [Profit] > 10000

OR

If any one or both of the expressions or Boolean values present on both sides of AND operator is evaluated to be TRUE, then the result is TRUE. Else the result is FALSE.

[Ship Date] > April 1, 2012 OR [Profit] > 10000

NOT

This operator negates the Boolean value of the expression present after it.

NOT [Ship Date] > April 1, 2012

Operator Precedence

下表描述了运算符的评估顺序。最上面一行优先级最高。处于同一行的运算符具有相同的优先级。如果两个运算符具有相同的优先级,则从左到右在公式中对其进行评估。还可以使用括号。圆括号内侧内容在圆括号外侧内容前评估。

The following table describes the order in which operators are evaluated. The top row has the highest precedence. Operators on the same row have the same precedence. If two operators have the same precedence, they are evaluated from left to right in the formula. Also parentheses can be used. The inner parentheses are evaluated before the outer parentheses.

Precedence

Operator

1

–(negate)

2

^(power)

3

*, /, %

4

+, –

5

==, >, <, >=, ⇐, !=

6

NOT

7

AND

8

OR

Tableau - Functions

任何数据分析都涉及大量计算。在 Tableau 中,计算编辑器用于将计算应用于正在分析的字段。Tableau 具有许多内置函数,有助于创建复杂计算的表达式。

Any data analysis involves a lot of calculations. In Tableau, the calculation editor is used to apply calculations to the fields being analyzed. Tableau has a number of inbuilt functions which help in creating expressions for complex calculations.

以下是不同函数类别的说明。

Following are the description of different categories of functions.

  1. Number Functions

  2. String Functions

  3. Date Functions

  4. Logical Functions

  5. Aggregate Functions

Number Functions

这些是用于数字计算的函数。它们仅将数字作为输入。以下是一些重要的数字函数示例。

These are the functions used for numeric calculations. They only take numbers as inputs. Following are some examples of important number functions.

Function

Description

Example

CEILING (number)

Rounds a number to the nearest integer of equal or greater value.

CEILING(2.145) = 3

POWER (number, power)

Raises the number to the specified power.

POWER(5,3) = 125

ROUND (number, [decimals])

Rounds the numbers to a specified number of digits.

ROUND(3.14152,2) = 3.14

String Functions

字符串函数用于字符串处理。以下是带有示例的一些重要的字符串函数

String Functions are used for string manipulation. Following are some important string functions with examples

Function

Description

Example

LEN (string)

Returns the length of the string.

LEN("Tableau") = 7

LTRIM (string)

Returns the string with any leading spaces removed.

LTRIM(" Tableau ") = "Tableau"

REPLACE (string, substring, replacement)

Searches the string for substring and replaces it with a replacement. If the substring is not found, the string is not changed.

REPLACE("GreenBlueGreen", "Blue", "Red") = "GreenRedGreen"

UPPER (string)

Returns string, with all characters uppercase.

UPPER("Tableau") = "TABLEAU"

Date Functions

Tableau 具有各种日期函数来执行涉及日期的计算。所有日期函数都使用 date_part ,这是一个字符串,指定日期的一部分,例如月份、日期或年份。下表列出了一些重要的日期函数示例。

Tableau has a variety of date functions to carry out calculations involving dates. All the date functions use the date_part which is a string indicating the part of the date such as - month, day, or year. Following table lists some examples of important date functions.

Function

Description

Example

DATEADD (date_part, increment, date)

Returns an increment added to the date. The type of increment is specified in date_part.

DATEADD ('month', 3, 2004-04-15) = 2004-0715 12:00:00 AM

DATENAME (date_part, date, [start_of_week])

Returns date_part of date as a string. The start_of_week parameter is optional.

DATENAME('month', 200404-15) = "April"

DAY (date)

Returns the day of the given date as an integer.

DAY(2004-04-12) = 12

NOW( )

Returns the current date and time.

NOW( ) = 2004-04-15 1:08:21 PM

Logical Functions

这些函数计算某些单一值或表达式的结果,并生成布尔输出。

These functions evaluate some single value or the result of an expression and produce a boolean output.

Function

Description

Example

IFNULL (expression1, expression2)

The IFNULL function returns the first expression if the result is not null, and returns the second expression if it is null.

IFNULL([Sales], 0) = [Sales]

ISDATE (string)

The ISDATE function returns TRUE if the string argument can be converted to a date, and FALSE if it cannot.

ISDATE("11/05/98") = TRUE ISDATE("14/05/98") = FALSE

MIN(expression)

The MIN function returns the minimum of an expression across all records or the minimum of two expressions for each record.

Aggregate Functions

Function

Description

Example

AVG(expression)

Returns the average of all the values in the expression. AVG can be used with numeric fields only. Null values are ignored.

COUNT (expression)

Returns the number of items in a group. Null values are not counted.

MEDIAN (expression)

Returns the median of an expression across all records. Median can only be used with numeric fields. Null values are ignored.

STDEV (expression)

Returns the statistical standard deviation of all values in the given expression based on a sample of the population.

Tableau - Numeric Calculations

Tableau 中的数字计算使用公式编辑器中提供的广泛内置函数来完成。

Numeric calculations in Tableau are done using a wide range of inbuilt functions available in the formula editor.

在本章中,我们将看到如何将计算应用到字段。计算可以像减去两个字段的值或对单个字段应用聚合函数一样简单。

In this chapter, we will see how to apply calculations to the fields. The calculations can be as simple as subtracting the values of two fields or applying an aggregate function to a single field.

以下是在 Tableau 中创建计算字段并使用数字函数的步骤。

Following are the steps to create a calculation field and use numeric functions in it.

Create Calculated Field

连接到 Sample-superstore 时,转至“分析”菜单,然后单击“创建计算字段”,如下图所示。

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 numbers.

calculation edit

Create a Formula

为了研究不同产品运输方式的利润与折扣之间的差异,创建一个公式,减去利润的折扣,如下图所示。此外,将此字段命名为 profit_n_discount

To study the difference between profit and discount for different shipping mode of the products, create a formula subtracting the discount from the profit as shown in the following screenshot. Also, name this field as profit_n_discount.

numeric calc 3

Using the Calculated Field

上述计算出的字段可通过将该字段拖动至"行"架来应用到视图中,如下图所示。它制作出的条形图显示了不同运输方式的利润和折扣之间的差值。

The above calculated field can be used in the view by dragging it to the Rows shelf as shown in the following screenshot. It produces a bar chart showing the difference between profit and discount for different shipping modes.

numeric calc 4

Applying Aggregate Calculations

同如上所示,您可以使用聚合函数来创建计算字段。此处,为不同的运输方式创建 AVG(销售) 值。如以下屏幕截图中所示,在计算编辑器中编写公式。

In a similar manner as above, you can create a calculated field using aggregate function. Here, create AVG(sales) values for different ship mode. Write the formula in the calculation editor as shown in the following screenshot.

numeric calc 1

单击"确定"后并将 Avg_Sales 字段拖至"行"架,您将得到以下视图。

On clicking OK and dragging the Avg_Sales field to the Rows shelf, you will get the following view.

numeric calc 2

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

Tableau - Date Calculations

日期是大多数数据分析场景中广泛使用的一个关键字段。因此,Tableau 提供了许多涉及到日期的内置函数。你可以进行简单的日期操作,例如添加或减去日期中的天数。你还可以创建涉及到日期的复杂表达式。

Dates are one of the key fields which is extensively used in most of the data analysis scenarios. Hence, Tableau provides a large number of inbuilt functions involving dates. You can carry out simple date manipulations such as adding or subtracting days from a date. You can also create complex expressions involving dates.

以下是创建计算字段并在其中使用日期函数的步骤。

Following are the steps to create a calculation field and use date 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 available in Tableau. You can change the dropdown value and see only the functions related to Date.

date calc 1

Create a Formula

现在,找出销售量以及自 2009 年 3 月 21 日以来的销售日期差异(以月为单位)。为此,创建如下面的屏幕截图所示的公式。

Now, find out the sales volume along with the difference in the date of sales in months from 21st March 2009. For this, create the formula as shown in the following screenshot.

date 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. Also drag the ship Date with months. The following screenshot shows the Sales values.

date calc 3

Tableau - Table Calculations

这些计算应用于整个表中的值。例如,要计算一个累积总计或累积平均值,我们需要对一整列应用一个单一的计算方法。这类计算无法在某些选定的行上执行。

These are the calculations which are applied to the values in the entire table. For example, for calculating a running total or running average, we need to apply a single method of calculation to an entire column. Such calculations cannot be performed on some selected rows.

表有一个称为 Quick Table Calculation 的功能,该功能用于创建这类计算。在快速表计算中应用的步骤如下−

Table has a feature called Quick Table Calculation, which is used to create such calculations. The steps to be applied in Quick Table calculation are as follows −

Step 1 −选择要应用表计算的度量,然后将其拖到列架子上。

Step 1 − Select the measure on which the table calculation has to be applied and drag it to column shelf.

Step 2 −右键单击该度量,然后选择选项“快速表计算”。

Step 2 − Right-click the measure and choose the option Quick Table Calculation.

Step 3 −选择一个以下选项应用于该度量。

Step 3 − Choose one of the following options to be applied on the measure.

  1. Running Total

  2. Difference

  3. Percent Difference

  4. Percent of Total

  5. Rank

  6. Percentile

  7. Moving Average

  8. Year to Date (YTD) Total

  9. Compound Growth Rate

  10. Year over Year Growth

  11. Year to Date (YTD) Growth

Example

让我们按照上述步骤计算数据源中赚取利润的累积总计。使用名为示例 - superstore.xls 的数据源。

Let’s calculate the running total of the profits earned for the data source following the above steps. Use the data source named sample – superstore.xls.

Tableau - LOD Expressions

Level of Detail (LOD) expressions 用于在数据源级别运行涉及多个维度的复杂查询,而不是将所有数据传送到 Tableau 界面。添加维度到已经计算的聚合值是简单的示例。

Level of Detail (LOD) expressions are used to run complex queries involving many dimensions at the data source level instead of bringing all the data to Tableau interface. A simple example is adding dimension to an already calculated aggregate value.

Types of LOD

有三种主要的 LOD 表达式类型。

There are three main types of LOD expressions.

  1. FIXED LOD This expression computes values using the specified dimensions without reference to any other dimensions in the view.

  2. INCLUDE LOD This level of detail expressions compute values using the specified dimensions in addition to whatever dimensions are in the view.

  3. EXCLUDE LOD These levels of detail expressions subtract dimensions from the view level of detail.

FIXED Level of Detail Expressions

找出每个地区每个州的销售额。在此,首先使用如下屏幕截图中所示的公式创建名为区域销售的公式字段。

Find the amount of Sales for each state in each region. Here, first create the formula field named Regional Sales using the formula as shown in the following screenshot.

fixed lod 1

接下来,将区域和州字段拖放到行搁置,并将计算字段拖放到标记卡下的文本搁置。还要将区域字段拖放到颜色搁置。这会生成以下视图,显示不同州的固定值。这是因为我们已将维度固定为区域以便计算销售额。

Next, drag the Region and State field to the Rows shelf and the calculated field to the Text shelf under the Marks card. Also drag the Region field to the Color shelf. This produces the following view, which shows a fixed value for different states. That is because we have fixed the dimension as region for the calculation of Sales value.

fixed lod 2

INCLUDE Level of Detail Expressions

INCLUDE 상세 수준 표현식은 뷰에 있는 어떠한 차원과 함께 지정된 차원을 사용하여 값을 산출합니다. 각 제품 하위 카테고리에 대한 주별 매출을 계산합니다.

INCLUDE level of detail expressions compute values using the specified dimensions in addition to whatever dimensions are in the view. Calculate the sum of sales per state for each sub-category of products.

이를 위해 하위 카테고리 필드를 행 搁置로 드래그합니다. 그런 다음 다음 스크린샷에 표시된 대로 열 搁置에 표현식을 작성합니다. 이렇게 하면 계산에서 두 차원이 모두 포함된 다음과 같은 뷰가 생성됩니다.

For this, drag the Sub-Category field to the Rows shelf. Then, write the expression in the Columns shelf as shown in the following screenshot. It produces the following view which includes both the dimensions in the calculations.

include lod 1

EXCLUDE Level of Detail Expressions

EXCLUDE 상세 수준 표현식은 뷰 상세 수준에서 제외할 차원을 지정합니다. 모든 월에 대해 계산된 매출 수치에서 지역을 제외합니다. 다음 스크린샷에 표시된 대로 수식을 만듭니다.

EXCLUDE level of detail expressions specify dimensions to exclude from the view level of detail. Exclude Region from Sales figure calculated for every month. Create the formula as shown in the following screenshot.

exclude lod 1

관련 필드를 해당 搁置로 드래그하면 다음 스크린샷에 표시된 대로 EXCLUDE LOD의 최종 뷰를 확인할 수 있습니다.

On dragging the relevant fields to the respective shelves, you will get the final view for the EXCLUDE LOD as shown in the following screenshot.

exclude lod 2

Tableau - Basic Sorting

데이터 분류는 데이터 분석에서 매우 중요한 기능입니다. Tableau에서는 차원이라고 하는 필드의 데이터를 분류할 수 있습니다. Tableau에서는 두 가지 방법으로 분류가 수행됩니다.

Sorting of data is a very important feature of data analysis. Tableau allows the sorting of data of the fields, which are called dimensions. There are two ways in which Tableau carries out the sorting.

  1. Computed Sorting is the sort directly applied on an axis using the sort dialog button.

  2. Manual Sorting is used to rearrange the order of dimension fields by dragging them next to each other in an ad hoc fashion.

Computed Sorting

此类排序涉及选择要排序的字段,然后使用排序对话框直接应用排序。您可以选择升序或降序的排序顺序,并选择应用排序的字段。

This type of sorting involves choosing a field to be sorted and directly applying the sort using the sort dialog box. You have the option to choose the sort order as ascending or descending and choose the field on which to apply the sort.

Example

选择示例超市以使用维度 order date 和 Subcategory 对名为 discount 的字段应用排序,如下所示。结果显示子类别的名称按降序排列,并按年份排列。

Choose Sample-Superstore to apply sorting on the field named discount by using the dimensions order date and Subcategory as shown below. The result shows the name of the sub-categories in a descending order arranged for each year.

Manual Sorting

这基本上是更改可视化元素在屏幕中出现的顺序。例如,您希望按降序显示不同产品部分的销售量,但是您可以自己选择顺序。此类排序并不完全基于数字或文本值,而是表示用户对排序方式的选择。因此,它们被称为手动排序。

This is basically changing the order in which the visualization elements appear in the screen. For example, you want to show the sales volume of different product segment in a descending order, however you have your own choice of order. This sort is not as per the exact values of number or text, rather they represent the user’s choice of ordering. Hence, they are called as manual sorting.

在以下示例中,即使 Home Office 的销售额最低,您仍会将名为 Home Office 的细分移至名为 Consumer 的细分下方。

In the following example, you move the segment named Home Office, below the segment named Consumer, even though the sales volume of Home Office is the lowest.

Tableau - Basic Filters

筛选是移除结果集中某些值或值范围的过程。Tableau 筛选功能允许使用字段值以及高级计算或基于上下文的筛选器,以适应各种情况。在本章中,您将了解 Tableau 中提供的一些基本筛选器。

Filtering is the process of removing certain values or range of values from a result set. Tableau filtering feature allows both simple scenarios using field values as well as advanced calculation or context-based filters. In this chapter, you will learn about the basic filters available in Tableau.

Tableau 中提供了三种类型的基本筛选器。它们如下所示 -

There are three types of basic filters available in Tableau. They are as follows −

  1. Filter Dimensions are the filters applied on the dimension fields.

  2. Filter Measures are the filters applied on the measure fields.

  3. Filter Dates are the filters applied on the date fields.

Filter Dimensions

这些筛选器还应用于维度字段。典型示例包括基于文本类别的筛选或带有逻辑表达式的数值,大于或小于条件。

These filters are applied on the dimension fields. Typical examples include filtering based on categories of text or numeric values with logical expressions greater than or less than conditions.

Example

我们使用 Sample - Superstore 数据源对产品的子类别应用维度筛选器。我们创建一个视图,按配送方式显示各子类别产品的利润。为此,将维度字段“子类别”拖动到“行”架,并将度量字段“利润”拖动到“列”架。

We use the Sample - Superstore data source to apply dimension filters on the sub-category of products. We create a view for showing profit for each sub-category of products according to their shipping mode. For it, drag the dimension field “Sub-Category” to the Rows shelf and the measure field “profit” to the Columns shelf.

filter diemnsion 1

接下来,将“子类别”维度拖动到“筛选器”架,以打开“筛选器”对话框。单击列表底部的“无”按钮,取消选择所有细分。然后,选择对话框右下角的“排除”选项。最后,选择“标签”和“存储”,然后单击“确定”。以下屏幕截图显示了上述两个类别被排除后的结果。

Next, drag the Sub-Category dimension to the Filters shelf to open the Filter dialog box. Click the None button at the bottom of the list to deselect all segments. Then, select the Exclude option in the lower right corner of the dialog box. Finally, select Labels and Storage and then click OK. The following screenshot shows the result with the above two categories excluded.

filter diemnsion 2

Filter Measures

这些筛选器应用于度量字段。筛选基于应用于度量字段的计算。因此,虽然在维度筛选器中您只使用值进行筛选,而在度量筛选器中则使用基于字段的计算。

These filters are applied on the measure fields. Filtering is based on the calculations applied to the measure fields. Hence, while in dimension filters you use only values to filter, in measures filter you use calculations based on fields.

Example

您可以使用 Sample - Superstore 数据源对利润平均值应用维度筛选器。首先,创建一个视图,其中配送方式和子类别作为维度,利润平均值如下图所示。

You can use the Sample - Superstore data source to apply dimension filters on the average value of the profits. First, create a view with ship mode and subcategory as dimensions and Average of profit as shown in the following screenshot.

filter measure 1

接下来,将“平均值(利润)”值拖动到筛选器窗格。选择“平均值”作为筛选器模式。接下来,选择“至少”,并给出筛选满足这些条件的行的一个值。

Next, drag the AVG (profit) value to the filter pane. Choose Average as the filter mode. Next, choose "At least" and give a value to filter the rows, which meet these criteria.

filter measure 2 1

完成上述步骤后,我们得到了最后的视图,其中只显示了平均利润大于 20 的子类别。

After completion of the above steps, we get the final view below showing only the subcategories whose average profit is greater than 20.

filter measure 2

Filter Dates

Tableau 在应用日期字段时以三种方式处理日期字段。它可以通过采用与今天比较的相对日期、绝对日期或日期范围来应用筛选器。当将日期字段从筛选器窗格拖出时,会显示这每个选项。

Tableau treats the date field in three different ways while applying the date field. It can apply filter by taking a relative date as compared to today, an absolute date, or range of dates. Each of this option is presented when a date field is dragged out of the filter pane.

Example

我们选择 sample - Superstore 数据源,并创建一个视图,其中订单日期在列架中,利润在行架中,如下图所示。

We choose the sample - Superstore data source and create a view with order date in the column shelf and profit in the rows shelf as shown in the following screenshot.

filter date 1

接下来,将“订单日期”字段拖动到筛选器架上,然后在筛选器对话框中选择“日期范围”。按以下屏幕截图中的方式选择日期。

Next, drag the "order date" field to the filter shelf and choose Range of dates in the filter dialog box. Choose the dates as shown in the following screenshot.

filter date 2

单击“确定”后,将显示包含已选择日期范围的结果的最终视图,如下图所示。

On clicking OK, the final view appears showing the result for the chosen range of dates as seen in the following screenshot.

filter date 3

Tableau - Quick Filters

Tableau 中的许多筛选器类型都可以通过右键单击维度或度量轻松使用。这些称为快速筛选器的筛选器具有足够的功能来解决大多数常见的筛选需求。

Many filter types in Tableau are quickly available using the right-click option on the dimension or measure. These filters known as Quick filters have enough functionality to solve most of the common filtering needs.

以下屏幕截图显示了如何访问快速筛选器。

The following screenshot shows how the quick filters are accessed.

Filter options

下面列出了各种快速筛选器及其用途。

Following is a list of various quick filters and their use.

Filter name

Purpose

Single Value (List)

Select one value at a time in a list.

Single Value (Dropdown)

Select a single value in a drop-down list.

Multiple Values (List)

Select one or more values in a list.

Multiple Values (Dropdown)

Select one or more values in a drop-down list.

Multiple Values (Custom List)

Search and select one or more values.

Single Value (Slider)

Drag a horizontal slider to select a single value.

Wildcard Match

Select values containing the specified characters.

Example

考虑示例超市数据源以应用一些快速筛选器。在以下示例中,选择子类别作为行,选择销售额作为列,默认情况下将创建一个水平条形图。接下来,将子类别字段拖到筛选器窗格。所有子类别都出现在图表旁边。使用表达式 a * 应用通配符筛选,该表达式选择所有以 “a” 开始的子类别名称。

Consider the Sample-Superstore data source to apply some quick filters. In the following example, choose sub-category as the row and sales as the column which by default produces a horizontal bar chart. Next, drag the sub-category field to the filters pane. All the subcategories appear next to the chart. Apply wildcard filtering using the expression a* which selects all subcategory name starting with “a”.

以下屏幕显示了应用此筛选器的结果,其中仅显示以 “A” 开头的子类别。

The below screen shows the result of applying this filter where only the sub-categories starting with “A” are displayed.

wildcar filters

Clearing the Filter

通过应用筛选器完成分析后,使用清除筛选器选项将其删除。为此,请转到筛选器窗格,右键单击字段名称,然后选择清除筛选器,如下面的屏幕截图所示。

Once the analysis is complete by applying the filter, remove it by using the clear filter option. For this, go to the filter Pane, right-click on the field name and choose Clear Filter as shown in the following screenshot.

clear filters

Tableau - Context Filters

Tableau 中的普通筛选器彼此独立。这意味着每个筛选器都会读取源数据中的所有行,并创建其自己的结果。但是,在某些情况下,您可能希望第二个筛选器仅处理第一个筛选器返回的记录。在这种情况下,第二个筛选器称为从属筛选器,因为它们仅处理通过上下文筛选器的数据。上下文筛选器有两种主要用途。

The normal filters in Tableau are independent of each other. It means each of the filter reads all the rows from the source data and creates its own result. However, there may be scenarios where you might want the second filter to process only the records returned by the first filter. In such a case, the second filter is known as dependent filters because they process only the data that passes through the context filter. Context Filters serve two main purposes.

  1. Improves performance − If you set a lot of filters or have a large data source, the queries can be slow. You can set one or more context filters to improve the performance.

  2. Creates a dependent numerical or top N filter − You can set a context filter to include only the data of interest, and then set a numerical or a top N filter.

Creating Context Filter

使用示例超级商店,找出称为家具的类别的产品前 10 个子类。为实现此目标,请执行以下步骤。

Using the Sample-superstore, find the top 10 Sub-Category of products for the category called Furniture. To achieve this objective, following are the steps.

Step 1 - 将维度子类拖到行功能区,将度量销售额拖到列功能区。选择水平条形图作为图表类型。将维度子类再次拖到筛选器功能区。您将获得以下图表。

Step 1 − Drag the dimension Sub-Category to the Rows shelf and the measure Sales to the Columns Shelf. Choose the horizontal bar chart as the chart type. Drag the dimension Sub-Category again to the Filters shelf. You will get the following chart.

context filter 1

Step 2 - 右键单击筛选器功能区中的字段子类,然后转到名为顶部选项的第四个选项卡。按字段选择选项。从下一个下拉列表中,选择按销售金额前 10 名,如下图所示。

Step 2 − Right-click on the field Sub-Category in the filter shelf and go the fourth tab named Top. Choose the option by field. From the next drop-down, choose the option Top 10 by Sales Sum as shown in the following screenshot.

context filter 2

Step 3 - 将维度类别拖到筛选器功能区。右键单击进行编辑并在常规选项卡下从列表中选择家具。正如您所见的,结果显示了三个产品子类别。

Step 3 − Drag the dimension Category to the filter shelf. Right-click to edit and under the general tab choose Furniture from the list. As you can see the result shows three subcategory of products.

context filter 3

Step 4 - 右键单击类别:家具筛选器,然后选择添加到上下文选项。这就生成了最终结果,显示了家具类别中排在前 10 个子类别中的产品子类别。

Step 4 − Right-click the Category: Furniture filter and select the option Add to Context. This produces the final result, which shows the subcategory of products from the category Furniture which are among the top 10 subcategories across all the products.

context filter 4

Tableau - Condition Filters

Tableau 中一个重要的筛选选项是对现有筛选器应用一些条件。这些条件可以很简单,例如仅查找高于一定金额的销售,也可以基于某个公式来查找复杂条件。还可以应用条件来创建范围筛选器。

One of the important filtering options in Tableau is to apply some conditions to already existing filters. These conditions can be very simple like finding only those sales which are higher than a certain amount or it can be a complex one based on a certain formula. The conditions can also be applied to create a range filter.

Creating a Condition Filter

使用 Sample-superstore,让我们找到所有细分市场中其销售额超过一百万的子类别产品。为实现这一目标,以下是步骤。

Using the Sample-superstore, let’s find that sub-category of products across all segments whose sales exceed one million. To achieve this objective, following are the steps.

Step 1 − 将维度细分和度量销售拖放到列功能区。接下来,将维度子类别拖放到行功能区。选择水平条形图选项。您将获得以下图表。

Step 1 − Drag the dimension segment and the measure Sales to the Column shelf. Next, drag the dimension Sub-Category to the Rows shelf. Choose the horizontal bar chart option. You will get the following chart.

condition filter 1

Step 2 − 将维度子类别拖放到筛选器功能区。右键单击进行编辑,然后转到条件选项卡。在此,选择按字段进行单选按钮选项。从下拉菜单中,选择销售额、总和和大于或等于符号,并指定值 100000。

Step 2 − Drag the dimension Sub-Category to the Filters Shelf. Right-click to edit and go to the tab Condition. Here, choose the radio option by field. From the drop-down, select Sales, Sum and greater than equal to symbol specifying the value 100000.

condition filter 2

在完成上述两个步骤后,我们得到一张图表,该图表仅显示满足条件的销售额达到所需金额的产品子类别。此外,还会针对满足条件的所有细分市场显示此内容。

On completion of the above two steps, we get a chart which shows only those subcategory of products, which have the required amount of sale. Also this is shown for all the available segments where the condition is met.

condition filter 3

Tableau - Top Filters

Tableau 筛选器中的首要选项用于限制筛选器的结果集。例如,从销售额的众多记录中,您只想获取前 10 个值。您可以使用内置选项通过多种方式限制记录或通过创建公式来应用此筛选器。在本章中,您将探索内置选项。

The Top option in Tableau filter is used to limit the result set from a filter. For example, from a large set of records on sales you want only the top 10 values. You can apply this filter using the inbuilt options for limiting the records in many ways or by creating a formula. In this chapter, you will explore the inbuilt options.

Creating a Top Filter

使用示例超级商店,找出代表销售额前五名的产品的子类别。要实现此目标,请执行以下步骤。

Using the Sample-superstore, find the sub-category of products which represents the top 5 sales amount. To achieve this objective, following are the steps.

Step 1 - 将维度子类别拖到行架和度量销售到列架。选择水平条形图作为图表类型。Tableau 将显示以下图表。

Step 1 − Drag the dimension Sub-Category to the Rows shelf and the Measure Sales to the Columns shelf. Choose the horizontal bar as the chart type. Tableau shows the following chart.

tio filter 1

Step 2 - 右键单击字段子类别,然后转到名为“顶部”的选项卡。在此,按字段选择第二个单选按钮。从下拉列表中选择按总销售额排名前 5 的选项。

Step 2 − Right-click on the field Sub-Category and go to the tab named Top. Here, choose the second radio option by field. From the drop-down, choose the option Top 5 by Sum of Sales.

tio filter 2

完成上述步骤后,您将获得以下图表,其中显示了按销量排名前 5 的产品子类别。

On completion of the above step, you will get the following chart, which shows the top 5 Sub-Category of products by sales.

tio filter 3

Tableau - Filter Operations

任何数据分析和可视化工作都需要对数据进行广泛筛选。Tableau 提供各种筛选选项来满足这些需求。有很多内置函数用于使用维度和度量对记录应用筛选。度量的筛选选项提供了数字计算和比较。维度的筛选选项提供从列表中选择字符串值或使用自定义值列表。在本章中,你将了解各种选项以及编辑和清除筛选的步骤。

Any data analysis and visualization work involves the use of extensive filtering of data. Tableau has a very wide variety of filtering options to address these needs. There are many inbuilt functions for applying filters on the records using both dimensions and measures. The filter option for measures offers numeric calculations and comparison. The filter option for dimension offers choosing string values from a list or using a custom list of values. In this chapter, you will learn about the various options as well as the steps to edit and clear the filters.

Creating Filters

通过将所需字段拖到标记卡上方筛选器面板中,可以创建筛选器。通过将度量销售额拖到列面板和维度子类别拖到行面板中,创建水平条形图。再次将度量销售额拖到筛选器面板中。创建此筛选器后,右键单击并从弹出菜单中选择编辑筛选器选项。

Filters are created by dragging the required field to the Filters shelf located above the Marks card. Create a horizontal bar chart by dragging the measure sales to the Columns shelf and the dimension Sub-Category to the Rows shelf. Again drag the measure sales into the Filters shelf. Once this filter is created, right-click and choose the edit filter option from the pop-up menu.

Editing filter

Creating Filters for Measures

度量是数字字段。因此,此类字段的筛选器选项涉及选择值。Tableau 为度量提供了以下类型的筛选器。

Measures are numeric fields. So, the filter options for such fields involve choosing values. Tableau offers the following types of filters for measures.

  1. Range of Values − Specifies the minimum and maximum values of the range to include in the view.

  2. At Least − Includes all values that are greater than or equal to a specified minimum value.

  3. At Most − Includes all values that are less than or equal to a specified maximum value.

  4. Special − Helps you filter on Null values. Include only Null values, Non-null values, or All Values.

以下工作表显示了这些选项。

Following worksheet shows these options.

Adding filter measure

Creating Filters for Dimensions

维度是不包含字符串值的描述性字段。Tableau 为维度提供了以下类型的筛选器。

Dimensions are descriptive fields having values which are strings. Tableau offers the following types of filters for dimensions.

  1. General Filter − allows to select specific values from a list.

  2. Wildcard Filter − allows to mention wildcards like cha* to filter all string values starting with cha.

  3. Condition Filter − applies conditions such as sum of sales.

  4. Top Filter − chooses the records representing a range of top values.

以下工作表显示了这些选项。

Following worksheet shows these options.

Adding filter dimension

Clearing Filters

可以通过选择清除筛选器选项轻松删除筛选器,如下图所示。

Filters can be easily removed by choosing the clear filter option as shown in the following screenshot.

Clear filter

Tableau - Bar Chart

条形图以矩形条表示数据,条的长度与变量值的比例相同。当您将维度拖到行架并测量到列架时,Tableau 会自动生成条形图。我们还可以在“显示方式”按钮中使用条形图选项。如果数据不适合条形图,则该选项将自动变为灰色。

A bar chart represents data in rectangular bars with the length of the bar proportional to the value of the variable. Tableau automatically produces a bar chart when you drag a dimension to the Row shelf and measure to the Column shelf. We can also use the bar chart option present in the Show Me button. If the data is not appropriate for bar chart, then this option will be automatically greyed out.

在 Tableau 中,可以使用维度和度量创建多种类型的条形图。

In Tableau, various types of bar charts can be created by using a dimension and a measure.

Simple Bar Chart

从示例超级商店中,选择维度,将利润拖到列架,并将子类别拖到行架。它会自动生成一个水平条形图,如以下屏幕截图所示。如果没有,您可以从“显示方式”工具中选择图表类型以获得以下结果。

From the Sample-Superstore, choose the dimension, take profit to the columns shelf and Sub-Category to the rows shelf. It automatically produces a horizontal bar chart as shown in the following screenshot. In case, it does not, you can choose the chart type from the Show Me tool to get the following result.

barchart 1

Bar Chart with Color Range

您可以根据条形图的范围对其应用颜色。条形图越长,色调越深;条形图越短,色调越浅。为此,将利润字段拖到“标记”窗格下的调色板。还要注意,它会为负条形图生成不同的颜色。

You can apply colors to the bars based on their ranges. The longer bars get darker shades and the smaller bars get the lighter shades. To do this, drag the profit field to the color palette under the Marks Pane. Also note that, it produces a different color for negative bars.

barchart 2

Stacked Bar Chart

您可以在上述条形图中添加另一个维度以生成堆叠条形图,在每个条中显示不同的颜色。将名为细分维度的字段拖到“标记”窗格并将其放入颜色中。将显示以下图表,其中显示了每个条形图中每个细分的分布。

You can add another dimension to the above bar chart to produce a stacked bar chart, which shows different colors in each bar. Drag the dimension field named segment to the Marks pane and drop it in colors. The following chart appears which shows the distribution of each segment in each bar.

barchart 4

Tableau - Line Chart

在折线图中,沿图表区域的两条轴取一个度量值和一个维度。每条观测记录的对值成为一个点,所有这些点的连接形成一条线,显示所选维度和度量值之间的变化或关系。

In a line chart, a measure and a dimension are taken along the two axes of the chart area. The pair of values for each observation becomes a point and the joining of all these points create a line showing the variation or relationship between the dimensions and measures chosen.

Simple Line Chart

选择一个维度和一个度量值来创建一个简单的折线图。将维度 Ship Mode(运输方式)拖到“列”栏架中,将销售额拖到“行”栏架中。从“标记”卡中选择“折线图”。您将获得以下折线图,显示不同运输方式的销售额变化情况。

Choose one dimension and one measure to create a simple line chart. Drag the dimension Ship Mode to Columns Shelf and Sales to the Rows shelf. Choose the Line chart from the Marks card. You will get the following line chart, which shows the variation of Sales for different Ship modes.

line chart 1

Multiple Measure Line Chart

您可以在一条折线图中使用一个与两个或多个度量值一起使用的维度。这将生成多条折线图,每条折线图位于一个窗格中。每个窗格都表示维度与某个度量值的变化情况。

You can use one dimension with two or more measures in a line chart. This will produce multiple line charts, each in one pane. Each pane represents the variation of the dimension with one of the measures.

line chart 2

Line Chart with Label

构成折线图的每个点可以标为标签,以显示度量值的值。在这种情况下,将另一个度量值 Profit Ratio(利润率)拖放到“标记”卡的“标签”窗格中。选择平均值作为聚合,您将获得显示标签的以下图表。

Each of the points making the line chart can be labeled to make the values of the measure visible. In this case, drop another measure Profit Ratio into the labels pane in the Marks card. Choose average as the aggregation and you will get the following chart showing the labels.

line chart 3

Tableau - Pie Chart

饼状图将数据表示为不同大小和颜色的圆形切片。这些切片都有标签,并且图表中还显示了与每个切片相对应的数字。您可以从“标记”卡中选择饼状图选项来创建饼状图。

A pie chart represents data as slices of a circle with different sizes and colors. The slices are labeled and the numbers corresponding to each slice is also represented in the chart. You can select the pie chart option from the Marks card to create a pie chart.

Simple Pie Chart

选择一个维度和一个度量来创建简单的饼状图。例如,将名为区域的维度与名为利润的度量结合使用。将“区域”维度放到颜色和标签标记中。将“利润”度量拖到大小标记中。选择“饼状”作为图表类型。将显示以下图表,其中显示了 4 个不同颜色的区域。

Choose one dimension and one measure to create a simple pie chart. For example, take the dimension named region with the measure named profit. Drop the Region dimension in the colors and label marks. Drop the Profit measure into the size mark. Choose the chart type as Pie. The following chart appears which shows the 4 regions in different colors.

pie chart 1

Drill-Down Pie Chart

您可以选择具有层次结构的维度,并且随着您深入层次结构,图表的变化将反映所选维度的级别。在以下示例中,我们选取具有另外两个级别(制造商和产品名称)的维度子类别。选取度量利润并将其拖到标签标记。将显示以下饼状图,其中显示了每个切片的价值。

You can choose a dimension with hierarchy and as you go deeper into the hierarchy, the chart changes reflect the level of the dimension chosen. In the following example, we take the dimension Sub-Category which has two more levels - Manufacturer and Product Name. Take the measure profit and drop it to the Labels mark. The following pie chart appears which shows the values for each slice.

pie chart 3

在层次结构中再深入一层,我们将制造商作为标签,并且上述饼状图会变成以下饼状图。

Going one more level into the hierarchy, we get the manufacturer as the label and the above pie chart changes to the following one.

pie chart 2

Tableau - Crosstab

Tableau 中的交叉表图表也称为文本表,它以文本形式显示数据。该图表由一个或多个维度和一个或多个度量值组成。该图表还可以显示度量值字段值的不同计算,例如运行总计、百分比总计等。

A crosstab chart in Tableau is also called a Text table, which shows the data in textual form. The chart is made up of one or more dimensions and one or more measures. This chart can also show various calculations on the values of the measure field such as running total, percentage total, etc.

Simple Crosstab

使用 Sample-superstore(样品超级商店),我们计划获得每个区域中每个细分市场的销售金额。您需要使用可用的订单日期,按年份显示此数据。为实现此目标,请执行以下步骤。

Using the Sample-superstore, let’s plan to get the amount of sales for each segment in each region. You need to display this data for each year using the order dates available. To achieve this objective, following are the steps.

Step 1 − 将维度顺序日期拖放到列功能区。

Step 1 − Drag and drop the dimension order date to the columns shelf.

Step 2 − 将维度区域和细分拖放到行功能区。

Step 2 − Drag and drop the dimensions region and segment to the rows shelf.

Step 3 − 将度量销售拉到“标记”下的标签功能区。

Step 3 − Pull the measure Sales to the labels Shelf under Marks.

将显示以下图表,其中显示交叉表。

The following chart appears which shows the Crosstab.

cross tab1

Crosstab - Color Encoded

您可以通过将度量字段拖放到颜色功能区(如下图所示)来获取交叉表图表中的值颜色编码。该颜色编码显示了颜色强度,具体取决于度量的值。值越大,阴影越深,反之亦然。

You can get the values color encoded in the crosstab chart by dropping the measure field into the Color shelf as shown in the following screenshot. This color coding shows the strength of the color depending on the value of the measure. The larger values have a darker shade than the lighter values.

cross tab2

Crosstab with Row Percentage

除了颜色编码外,您还可以对度量中的值应用计算。在以下示例中,我们将应用计算以找到每一行中的总销售百分比,而不仅仅是销售数字。为此,右键单击标记卡中显示的 SUM(Sales),然后选择“添加表计算”选项。然后,选择“总和的百分比”,并将其汇总为“Table(Across)”。

In addition to the color encoding, you can also get calculations applied to the values from the measure. In the following example, we apply the calculation for finding the percentage total of sales in each row instead of only the sales figures. For this, right-click on SUM (Sales) present in the marks card and choose the option Add Table Calculation. Then, choose the percent of total and summarize it as Table (Across).

cross tab3

在以上屏幕中单击“确定”后,您将找到创建的带有百分比值交叉表图表,如下图所示。

On clicking OK in the screen above, you will find the crosstab chart created with percentage values as shown in the following screenshot.

cross tab4

Tableau - Scatter Plot

顾名思义,散点图显示了许多散布在笛卡尔平面上​​的点。它通过将数值变量的值绘制为笛卡尔平面中的 X 和 Y 坐标来创建。Tableau 至少需要一行架中的一个度量和一列架中的一个度量来创建散点图。但是,我们可以向散点图中添加维度字段,这些字段会在散点图中已存在的点上标记不同的颜色。

As the name suggests, a scatter plot shows many points scattered in the Cartesian plane. It is created by plotting values of numerical variables as X and Y coordinates in the Cartesian plane. Tableau takes at least one measure in the Rows shelf and one measure in the Columns shelf to create a scatter plot. However, we can add dimension fields to the scatter plot which play a role in marking different colors for the already existing points in the scatter graph.

Simple Scatter Plot

使用示例超级商店,让我们找出散布在笛卡尔平面上​​的销售额和利润数字的变化,并根据它们的产品子类别进行分布。要实现此目标,请执行以下步骤。

Using the Sample-superstore, let’s aim to find the variation of sales and profit figures as the two axes of the Cartesian plane is distributed according to their Sub-Category. To achieve this objective, following are the steps.

Step 1 - 将度量销售拖放到列架。

Step 1 − Drag and drop the measure Sales to the Columns shelf.

Step 2 - 将度量利润拖放到行架。

Step 2 − Drag and drop the measure Profit to the Rows shelf.

Step 3 - 将维度子类别拉到“标记”下的标签架。

Step 3 − Pull the dimension Sub-Category to the labels Shelf under Marks.

将显示以下图表,其中显示了利润和销售额如何分布在产品子类别中。

The following chart appears which shows how profit and sales is distributed across the Sub-Category of products.

sactter 1

Scatter Plot - Color Encoded

您可以通过将维度子类别拖动到标记卡下面的颜色区中来获取颜色编码的值。此图表显示了不同颜色散点图的散点。

You can get the values color encoded by dragging the dimension Sub-Category to the color Shelf under the Marks card. This chart shows the scatter points with different color for each point.

sactter 2

Drill-Down Scatter Plot

当您选择具有层次结构的维度时,相同的散点图可以显示不同的值。在下面的示例中,我们展开子类别字段以显示制造商的散点图值。

The same scatter plot can show different values when you choose a dimension with hierarchy. In the following example, we expand the Sub-Category field to show the scatter plot values for the Manufacturers.

sactter 3

Tableau - Bubble Chart

气泡图显示了作为圆簇的数据。维度字段中的每个值表示一个圆圈,而度量值表示这些圆圈的大小。由于值不会在任何行或列中显示,因此您可以将所需字段拖动到标记卡下的不同区中。

Bubble charts display data as a cluster of circles. Each of the values in the dimension field represents a circle whereas the values of measure represent the size of those circles. As the values are not going to be presented in any row or column, you can drag the required fields to different shelves under the marks card.

Simple Bubble Chart

使用样本超级市场,让我们计划找出不同运输方式的利润规模。要实现此目标,请执行以下步骤。

Using the Sample-superstore, let’s plan to find the size of profits for different ship mode. To achieve this objective, following are the steps.

Step 1 − 将度量利润拖放到标记卡下的尺寸区中。

Step 1 − Drag and drop the measure profit into the Size shelf under Marks card.

Step 2 − 将维度运输方式拖放到标记卡下的标签区中。

Step 2 − Drag and drop the dimension ship mode into the Labels shelf under Marks card.

Step 3 − 将维度运输方式拉到标记卡下的颜色区中。

Step 3 − Pull the dimension ship mode to the Colors shelf under Marks card.

出现以下图表。

The following chart appears.

bubble 1

Bubble Chart with Measure Values

您还可以显示决定圆圈大小的度量字段值。要执行此操作,请将销售度量拖放到标签区中。出现以下图表。

You can also show the values of the measure field which decides the size of the circles. To do this, drag the sales measure into the Labels shelf. The following chart appears.

bubble 2

Bubble Chart with Measure Colors

您可以使用深浅不同的单一颜色代替给每个圆圈不同的颜色。为此,将度量销售拖放到颜色区中。越高值表示越深阴影,而较小值表示较浅阴影。

Instead of coloring each circle with a different color, you can use a single color with different shades. For this, drag the measure sales into the color shelf. The higher values represent darker shades while the smaller values represent lighter shades.

bubble 3

Tableau - Bullet Graph

子弹图是条形图的一种变体。在此图表中,我们在一个范围内查找第二个度量中的变化的情况下,将一个度量的值与另一个度量进行比较,以找出第一个度量中的变化。这就像两个条形相互叠加一样,它们以图表的同一位置表示各自的值。可以将其视为将两个图表合并为一个图表,以便轻松查看比较结果。

A bullet chart is a variation of Bar chart. In this chart, we compare the value of one measure with another measure in the context of finding the variation in the first measure within a range of variations in the second measure. It is like two bars drawn upon one another to indicate their individual values at the same position in the graph. It can be thought of as combining two graphs as one to view a comparative result easily.

Creating Bullet Graph

使用样本超级市场,计划找出每个子类别中各自的销售额的利润规模。要实现此目标,请执行以下步骤。

Using the Sample-superstore, plan to find the size of profits for the respective sales figures in each Sub-Category. To achieve this objective, following are the steps.

Step 1 − 从数据窗格中将维度子类别拖放到列区中。

Step 1 − Drag and drop the dimension Sub-Category from the data pane into the column shelf.

Step 2 − 将度量利润和销售额拖放到行区中。

Step 2 − Drag and drop the measures Profit and Sales to the Rows shelf.

出现以下图表,显示两个度量为两个独立的条形图类别,每个类别都表示子类别的值。

The following chart appears which shows the two measures as two separate categories of bar charts, each representing the values for sub-categories.

bullet step 2

Step 3 − 将销售度量拖放到标记卡中。使用“显示方式”,选择子弹图选项。以下图表显示了子弹图。

Step 3 − Drag the sales measure to the Marks card. Using Show Me, choose the bullet graph option. The following chart shows the bullet graph.

bullet step 3

Tableau - Box Plot

箱线图又称为盒须图。它们显示沿轴分布的值。盒子表示中间 50% 的数据,即数据分布的中间两个四分位数。其余 50% 的数据在两侧由也称为须线的线表示,以显示不超过四分位间距 1.5 倍的所有点,即不超过邻接盒子宽度的 1.5 倍的所有点,或数据最大程度的所有点。

The box plots are also known as a box-and-whisker plots. They show the distribution of values along an axis. Boxes indicate the middle 50 percent of the data which is, the middle two quartiles of the data’s distribution. The remaining 50 percent of data on both sides is represented by lines also called whiskers, to display all points within 1.5 times the interquartile range, which is all points within 1.5 times the width of the adjoining box, or all points at the maximum extent of the data.

箱线图采用一个或多个度量,维度为零或多个。

The Box Plots take one or more measures with zero or more dimensions.

Creating a Box Plot

使用样本超级市场,计划找出每个运输方式值各自类别的利润规模。要实现此目标,请执行以下步骤。

Using the Sample-superstore, plan to find the size of profits for the respective category for each Ship mode values. To achieve this objective, following are the steps.

Step 1 − 将维度类别拖放到列架,将利润拖放到行架。同时将维度运输模式拖放到列架中类别的右侧。

Step 1 − Drag and drop the dimension category to the Columns shelf and profit to the Rows shelf. Also drag the dimension Ship mode to the right of Category in Columns shelf.

Step 2 − 从“展示方式”中选择箱形图。将出现下面的显示箱形图的图表。这里,Tableau 会自动将运输模式重新分配到标记卡中。

Step 2 − Choose Box-and-Whisker plot from Show Me. The following chart appears which shows the box plots. Here, Tableau automatically reassigns the ship mode to the Marks card.

box plot 1

Box Plot with Two Dimensions

可以通过向列架中添加另一个维度来使用两个维度创建箱形图。在上面的图表中,将区域维度添加到列架中。这将生成一个显示每个区域的箱形图的图表。

You can create box plots with two dimensions by adding another dimension to the Column shelf. In the above chart, add the region dimension to the Column shelf. This produces a chart which shows the box plots for each region.

Tableau - Tree Map

树形图以嵌套矩形显示数据。度量定义树形图的结构,度量定义单个矩形的大小或颜色。矩形很容易可视化,因为矩形的大小和颜色的阴影都反映了度量的值。

The tree map displays data in nested rectangles. The dimensions define the structure of the tree map and measures define the size or color of the individual rectangle. The rectangles are easy to visualize as both the size and shade of the color of the rectangle reflect the value of the measure.

使用一个或多个维度及一个或两个度量创建树形图。

A Tree Map is created using one or more dimension with one or two measures.

Creating a Tree Map

使用 Sample-superstore,计划查找每个运输模式值的利润大小。为达到此目的,请按照以下步骤进行操作。

Using the Sample-superstore, plan to find the size of profits for each Ship mode values. To achieve this objective, following are the steps.

Step 1 − 将度量利润拖放到标记卡中两次。一次拖放到大小架,另一次拖放到颜色架。

Step 1 − Drag and drop the measure profit two times to the Marks Card. Once to the Size shelf and again to the Color shelf.

Step 2 − 将维度运输模式拖放到标签架。从“展示方式”中选择树形图图表类型。将出现下面的图表。

Step 2 − Drag and drop the dimension ship mode to the Label shelf. Choose the chart type Tree Map from Show Me. The following chart appears.

tree map 1

Tree Map with Two Dimensions

可以将维度区域添加到上面的树形图中。拖放到它两次。一次拖放到颜色架,另一次拖放到标签架。出现的图表将显示四个表示四个区域的外框,然后显示嵌套在其中的表示运输模式的框。所有不同的区域现在都有不同的颜色。

You can add the dimension Region to the above Tree map chart. Drag and drop it twice. Once to the Color shelf and again to the Label shelf. The chart that appears will show four outer boxes for four regions and then the boxes for ship modes nested inside them. All the different regions will now have different colors.

Tableau - Bump Chart

凸点图用于根据度量值,将两个维度相互比较。它们对于探索值在时间维度、地点维度或与分析相关的其他维度上的排名的变化非常有用。

A Bump Chart is used to compare two dimensions against each other using one of the Measure value. They are very useful for exploring the changes in Rank of a value over a time dimension or place dimension or some other dimension relevant to the analysis.

凸点图包含两个维度,其中包含零个或更多度量值。

The Bump Chart takes two dimensions with zero or more measures.

Creating a Bump Chart

使用 Sample-superstore(样品超级商店),计划查找产品运输方式与子类别变化之间的差异。为实现此目标,请执行以下步骤。

Using the Sample-superstore, plan to find the variation of ship mode of products with the variation of the Sub-Category. To achieve this objective, following are the steps.

Step 1 - 将维度 Sub-Category(子类别)拖放到“列”栏架中。此外,将维度 Ship mode(运输方式)拖到“标记”卡下的“颜色”栏架中。将图表类型保留为“自动”。将出现以下图表。

Step 1 − Drag and drop the dimension Sub-Category to the Columns shelf. Also drag the dimension Ship mode to the Color shelf under Marks card. Leave the chart type to Automatic. The following chart appears.

bump chart 1

Step 2 - 接下来的,创建一个名为 Rank(排名)的计算字段。转到 Analysis(分析)→ Create Calculated Field(创建计算字段)。使用 Rank(排名)作为字段名称,并在运算区域中编写表达式 index()。这是一个内置函数,用于为分区中的当前行创建索引。单击“确定”,新字段将显示在度量值部分中。右键单击字段 Rank(排名),并将其转换为离散字段。

Step 2 − Next, create a calculated field called Rank. Go to Analysis → Create Calculated Field. Use Rank as the field name and write the expression index () in the calculation area. It is an inbuilt function that creates an index for the current row in the partition. Click OK and the new field will be visible in the measures section. Right-click on the field Rank and convert it to discrete.

Step 3 - 将 Rank(排名)拖到“行”栏架中。将出现以下图表,其中显示了维度 Sub-Category(子类别),其中每个运输方式均以其排名值的递增顺序排列。

Step 3 − Drag Rank to the Rows shelf. The following chart appears which shows the dimension Sub-Category with each ship mode arranged in an increasing order of their Rank value.

bump chart 2 create rank

Step 4 - 使用度量值利润对排名字段应用其他计算。右键单击 Rank(排名)并选择 Edit Table Calculation(编辑表格计算)。根据子类别分区并按运输方式设置,选择按利润字段进行排序。以下屏幕截图显示了应用的计算。

Step 4 − Apply some more calculation to the rank field using the measure Profit. Rightclick on Rank and choose Edit Table calculation. Choose the sorting by the field profit using partition by Sub-Category and addressed by ship mode. The following screenshot shows the calculations applied.

bump chart 3

完成上述步骤后,您将获得如下图所示的凸点图。它显示了各个子类别中每个运输方式的利润变化情况。

On completion of the above steps, you will get the bump chart as shown in the following screenshot. It shows the variation of profit for each ship mode across various subcategories.

bump chart 4

Tableau - Gantt Chart

甘特图显示了任务或资源的价值在一特定时间段内的进度。在项目管理和其他类型的一段时间内的变异研究中,它被广泛使用。因此,在甘特图中,时间维度是一个基本字段。

A Gantt chart shows the progress of the value of a task or resource over a period of time. It is extensively used in project management and other types of variation study over a period of time. Thus, in Gantt chart, time dimension is an essential field.

甘特图除了时间维度之外,至少需要一个维度和一个度量。

The Gantt chart takes at least a dimension and a measure in addition to the time dimension.

Creating a Gantt Chart

使用 Sample-superstore 计划根据一段时间内不同的产品子类别的运输方式来找出数量的变化。要实现这一目标,请按照以下步骤操作。

Using the Sample-superstore, plan to find the variation of quantities of different SubCategory of products according to their ship mode over a range of time. To achieve this objective, following are the steps.

Step 1 − 将维度 order date 拖动到 Columns 货架,将 Sub-Category 拖动到 Rows 货架。然后,将 order date 添加到 Filters 货架。右键单击 order date 将其转换为精确的日期值,如下面的屏幕截图所示。

Step 1 − Drag the dimension order date to the Columns shelf and Sub-Category to the Rows shelf. Next, add the order date to the Filters shelf. Right-click on order date to convert it to the exact date values as shown in the following screenshot.

gannt chart 1

Step 2 − 编辑筛选条件以选择一个日期范围。这是因为您希望获取各个日期值,而数据中有很多日期。该范围的创建方式如下面的屏幕截图所示。

Step 2 − Edit the filter condition to select a range of dates. It is because you want individual date values and there is a very large number of dates in the data. The range is created as shown in the following screenshot.

gannt chart 21

Step 3 − 将维度 ship mode 拖动到 Color 货架,将度量 quantity 拖动到 Marks 卡片下的 Size 货架。这样就能生成甘特图,如下面的屏幕截图所示。

Step 3 − Drag the dimension ship mode to the Color shelf and the measure quantity to the Size shelf under the Marks card. This produces the Gantt chart as shown in the following screenshot.

gannt chart final

Tableau - Histogram

直方图表示已分段到范围中的变量值的频率。直方图类似于条形图,但它将值分组到连续范围内。直方图中的每个条形表示该范围内存在的值的数量的高度。

A histogram represents the frequencies of values of a variable bucketed into ranges. Histogram is similar to bar chart but it groups the values into continuous ranges. Each bar in histogram represents the height of the number of values present in that range.

Tableau 通过采用一个度量来创建直方图。它为用于创建直方图中的度量创建了一个附加分段字段。

Tableau creates a histogram by taking one measure. It creates an additional bin field for the measure used in creating a histogram.

Creating a Histogram

使用 Sample-superstore,计划查找不同区域的销售量。为达到此目的,将名称为“数量”的度量拖放到行架。接着打开“展示方式”,然后选择直方图图表。下图显示了创建的图表。它按从 0 到 4811 的值对数量分段并将其分成 12 个分段,并显示了这些数量。

Using the Sample-superstore, plan to find the quantities of sales for different regions. To achieve this, drag the Measure named Quantity to the Rows shelf. Then open Show Me and select the Histogram chart. The following diagram shows the chart created. It shows the quantities automatically bucketed into values ranging from 0 to 4811 and divided into 12 bins.

histogram 1

Creating a Histogram with Dimension

还可以将维度添加到度量中创建直方图。这将创建堆叠的直方图。每根条形都将具有代表维度的值的分段。按照上面示例的步骤,将区域维度添加到标记卡下的颜色架中。这会创建下面的直方图,其中每根条形还包括不同区域的可视化。

You can also add Dimensions to Measures to create histograms. This will create a stacked histogram. Each bar will have stacks representing the values of the dimension. Following the steps of the above example, add the Region Dimension to the color Shelf under Marks Card. This creates the following histogram where each bar also includes the visualization for different regions.

histogram 2

Tableau - Motion Charts

动态图表使用 X 轴和 Y 轴显示数据,通过显示限定空间内数据点的运动以及线条颜色的变化来展示数据随时间的变化。动态图表的最大优势在于可以查看数据随时间变化的整个轨迹,而不仅仅是数据的快照。

Motion charts show data using the X and Y-axes, displaying changes over time by showing the movement of data points within the defined space as well as changes in the color of the lines. The main advantage of motion chart is to view the entire trail of how the data has changed over time and not just a snapshot of the data.

Tableau 需要一个时间维度和一个度量来创建动态图表。

Tableau needs one Time Dimension and one Measure to create a Motion chart.

Creating a Motion Chart

使用示例超级商店,计划找出月度的利润变化。为实现这一目标,以下为步骤。

Using the Sample-superstore, plan to find the variation of Profits over the months. To achieve this objective, following are the steps.

Step 1 − 将维度订单日期拖到列功能区。再次将其拖到页功能区。在页功能区中,右键单击订单日期并选择“月份”。然后将度量利润拖到行功能区。将出现以下图表。

Step 1 − Drag the Dimension Order Date to the Columns Shelf. Drag it again to the Pages Shelf. In the Pages shelf, right-click on the Order Date and choose Month. Then drag the measure Profit to the Rows Shelf. The following chart appears.

motion chart 1

Step 2 − 选中展示历史记录旁边的复选框,然后单击其旁边的下拉箭头。对于“要为其展示历史记录的标记”,选择“全部”。然后在“展示”下,选择“两者”。选择“标记”只显示点,选择“轨迹”只显示线条。单击播放按钮。将出现以下图表。

Step 2 − Put a check mark on the box next to Show History and then click on the dropdown arrow next to it. For “Marks to Show History For” select “All”. Then under “Show”, select “Both”. Selecting “Marks” shows only the points and selecting “Trails” shows only the line. Click the Play button. The following chart appears.

motion chart 2

Step 3 − 让图表从 1 月运行到 12 月将创建一个图表,该图表显示每年每个月的利润如何变化。请注意,随着数据的变化,最近几个月会变成较深的颜色,而历史数据会变成较浅的颜色。

Step 3 − Allowing the chart to run from January to December will create the chart which shows how the profits have varied over each month for all the years. Note that as the data changes the recent months get a darker shade of color and the historical data gets a lighter shade of color.

最后,您将获得以下图表。

Finally, you will get the following chart.

motion chart 3

Tableau - Waterfall Charts

瀑布图有效地显示顺序正负值的累积效应。它显示了值从哪里开始、结束以及如何递增到达那里。因此,我们能够看到连续数据点之间变化的大小和值的差异。

Waterfall charts effectively display the cumulative effect of sequential positive and negative values. It shows where a value starts, ends and how it gets there incrementally. So, we are able to see both the size of changes and difference in values between consecutive data points.

Tableau 需要一个维度和一个度量来创建瀑布图。

Tableau needs one Dimension and one Measure to create a Waterfall chart.

Creating a Waterfall Chart

使用 Sample-superstore,计划查找每个产品子类的销售额变化。要实现此目标,请执行以下步骤。

Using the Sample-superstore, plan to find the variation of Sales for each Sub-Category of Products. To achieve this objective, following are the steps.

Step 1 - 将维度子类别拖到“列”栏架中,将度量值销售额拖到“行”栏架中。按照递增的销售值对数据进行排序。为此,在将鼠标悬停在垂直轴中部时,使用显示在该轴中间的排序选项。完成此步骤后,将出现以下图表。

Step 1 − Drag the Dimension Sub-Category to the Columns shelf and the Measure Sales to the Rows shelf. Sort the data in an ascending order of sales value. For this, use the sort option appearing in the middle of the vertical axis when you hover the mouse over it. The following chart appears on completing this step.

water fall 1

Step 2 - 接下来的,右键单击“总和 (销售额)”值,并从表格计算选项中选择“运行总计”。将图表类型更改为“甘特条形图”。将出现以下图表。

Step 2 − Next, right-click on the SUM (Sales) value and select the running total from the table calculation option. Change the chart type to Gantt Bar. The following chart appears.

water fall 2

Step 3 - 创建一个名为 -sales 的计算字段,并为此计算字段的值提及以下公式。

Step 3 − Create a calculated field named -sales and mention the following formula for its value.

water fall 3

Step 4 - 将新创建的计算字段 (-sales) 拖到“标记”卡下的“大小”栏架中。上面的图表现在更改为生成以下图表,即瀑布图。

Step 4 − Drag the newly created calculated field (-sales) to the size shelf under Marks Card. The chart above now changes to produce the following chart which is a Waterfall chart.

water fall 4

Waterfall Chart with Color

接下来,通过将销售额度量值拖到“标记”卡下的“颜色”栏架中,为图表中的条形图赋予不同的色调。您将获得有颜色的以下瀑布图。

Next, give different color shades to the bars in the chart by dragging the Sales measure to the Color shelf under the Marks Card. You get the following waterfall chart with color.

water fall final

Tableau - Dashboard

仪表板是许多工作表和相关信息在一个地方的汇总显示。它用于同时比较和监控各种数据。不同的数据视图都会同时显示。仪表板显示在工作簿底部的选项卡中,并且通常会使用来自数据源的最新数据进行更新。在创建仪表板时,您可以从工作簿中的任何工作表中添加视图以及许多支持对象,例如文本区域、网页和图像。

A dashboard is a consolidated display of many worksheets and related information in a single place. It is used to compare and monitor a variety of data simultaneously. The different data views are displayed all at once. Dashboards are shown as tabs at the bottom of the workbook and they usually get updated with the most recent data from the data source. While creating a dashboard, you can add views from any worksheet in the workbook along with many supporting objects such as text areas, web pages, and images.

您添加到仪表板的每个视图都连接到其相应的工作表。因此,当您修改工作表时,仪表板将更新,当您修改仪表板中的视图时,工作表也会更新。

Each view you add to the dashboard is connected to its corresponding worksheet. So when you modify the worksheet, the dashboard is updated and when you modify the view in the dashboard, the worksheet is updated.

Creating a Dashboard

使用 Sample-superstore,计划创建一个仪表板,显示跨所有州的不同细分和产品子类别的销售额和利润。为实现此目标,步骤如下。

Using the Sample-superstore, plan to create a dashboard showing the sales and profits for different segments and Sub-Category of products across all the states. To achieve this objective, following are the steps.

Step 1 − 使用位于工作簿底部的添加工作表图标创建一个空白工作表。将维度细分拖到“列”选区,将维度子类别拖到“行”选区。将度量销售额拖放到“颜色”选区,将度量利润拖放到“大小”选区。此工作表称为主工作表。右键单击并重命名此工作表为 Sales_Profits 。出现以下图表。

Step 1 − Create a blank worksheet by using the add worksheet icon located at the bottom of the workbook. Drag the dimension Segment to the columns shelf and the dimension Sub-Category to the Rows Shelf. Drag and drop the measure Sales to the Color shelf and the measure Profit to the Size shelf. This worksheet is referred as the Master worksheet. Right-click and rename this worksheet as Sales_Profits. The following chart appears.

dashboard create master 1

Step 2 − 创建另一个表格以保存跨不同州的销售额详细信息。为此,将维度州拖到“行”选区,将度量销售额拖到“列”选区,如以下屏幕截图所示。接下来,对州字段应用筛选器以按降序排列销售额。右键单击并重命名此工作表为 Sales_state

Step 2 − Create another sheet to hold the details of the Sales across the States. For this, drag the dimension State to the Rows shelf and the measure Sales to the Columns shelf as shown in the following screenshot. Next, apply a filter to the State field to arrange the Sales in a descending order. Right-click and rename this worksheet as Sales_state.

dashboard create detail 2

Step 3 − 接下来,通过单击工作簿底部的创建新仪表板链接创建一个空白仪表板。右键单击并重命名仪表板为 Profit_Dashboard。

Step 3 − Next, create a blank dashboard by clicking the Create New Dashboard link at the bottom of the workbook. Right-click and rename the dashboard as Profit_Dashboard.

dashboard blank 3

Step 4 − 将两个工作表拖到仪表板中。在销售利润工作表的顶部边框线附近,您可以看到三个小图标。单击中间图标,当将鼠标悬停在该图标上时,该图标会显示提示使用作为筛选器。

Step 4 − Drag the two worksheets to the dashboard. Near the top border line of Sales Profit worksheet, you can see three small icons. Click the middle one, which shows the prompt Use as Filter on hovering the mouse over it.

dashboard create filter 4

Step 5 − 现在在仪表板中,单击名为机器细分和名为消费细分的代表子类别的框。

Step 5 − Now in the dashboard, click the box representing Sub-Category named Machines and segment named Consumer.

您会注意到,只有销售额达到此利润的州才会在名为 Sales_state 的右侧窗格中筛选出来。这说明了如何在仪表板中链接表格。

You can notice that only the states where the sales happened for this amount of profit are filtered out in the right pane named Sales_state. This illustrates how the sheets are linked in a dashboard.

Dashboard 6

Tableau - Formatting

Tableau 具有非常广泛的格式化选项,可以用来更改所创建的可视化内容的外观。你可以修改几乎每一个方面,例如字体、颜色、大小、布局等。你可以对内容和容器进行格式化,例如表、轴标签和工作簿主题等。

Tableau has a very wide variety of formatting options to change the appearance of the visualizations created. You can modify nearly every aspect such as font, color, size, layout, etc. You can format both the content and containers like tables, labels of axes, and workbook theme, etc.

下图显示了列出选项的格式菜单。在本章中,你将了解一些常用的格式化选项。

The following diagram shows the Format Menu which lists the options. In this chapter, you will touch upon some of the frequently used formatting options.

Formattinf options 1

Formatting the Axes

你可以通过将维度子类别拖放到列搁板中并将测量利润拖放到行搁板中来创建一个简单的条形图。单击纵轴并突出显示它。然后右键单击并选择格式。

You can create a simple bar chart by dragging and dropping the dimension Sub-Category into the Columns Shelf and the measure Profit into the Rows shelf. Click the vertical axis and highlight it. Then right-click and choose format.

format axes 1

Change the Font

单击左侧显示的格式栏中的字体下拉菜单。选择字体类型为 Arial,大小为 8pt。如下图所示。

Click the font drop-down in the Format bar, which appears on the left. Choose the font type as Arial and size as 8pt. as shown in the following screenshot.

format axes 2

Change the Shade and Alignment

你还可以更改轴中值的定位以及阴影颜色,如下图所示。

You can also change the orientation of the values in the axes as well as the shading color as shown in the following screenshot.

format axes 3

Format Borders

考虑将子类别放在列搁板中和将州放在行搁板中的交叉表图。现在,你可以使用格式化选项更改所创建的交叉表表的边框。在交叉表图上右键单击并选择格式。

Consider a crosstab chart with Sub-Category in the Columns shelf and State in the Rows shelf. Now, you can change the borders of the crosstab table created by using the formatting options. Right-click on crosstab chart and choose Format.

边框格式出现在左侧窗格中。选择如下图所示的选项。

The Format Borders appear in the left pane. Choose the options as shown in the following screenshot.

format tables 4

Tableau - Forecasting

预测是预测度量的未来值。有许多用于预测的数学模型。Tableau 使用称为 exponential smoothing 的模型。在指数平滑中,最近的观察值比更早的观察值赋予更大的权重。这些模型捕捉到数据变化的趋势或季节性并将其推断到未来。预测结果还可以成为创建的可视化中的一项。

Forecasting is about predicting the future value of a measure. There are many mathematical models for forecasting. Tableau uses the model known as exponential smoothing. In exponential smoothing, recent observations are given relatively more weight than older observations. These models capture the evolving trend or seasonality of the data and extrapolate them into the future. The result of a forecast can also become a field in the visualization created.

Tableau 采用时间维度和度量字段来创建预测。

Tableau takes a time dimension and a measure field to create a forecast.

Creating a Forecast

使用 Sample-superstore,预测下一年销售额度量的值。为达到此目的,请按照以下步骤进行操作。

Using the Sample-superstore, forecast the value of the measure sales for next year. To achieve this objective, following are the steps.

Step 1 − 在列架中使用订单日期(年份),在行架中使用销售额来创建折线图。转到分析选项卡,如以下屏幕截图所示,然后在“模型”类别下单击“预测”。

Step 1 − Create a line chart with Order Date (Year) in the columns shelf and Sales in the Rows shelf. Go to the Analysis tab as shown in the following screenshot and click Forecast under Model category.

forecast 1

Step 2 − 完成上述步骤后,你将找到设置各种预测选项的选项。将“预测长度”选择为 2 年,并将“预测模型”保留为“自动”,如下图截图所示。

Step 2 − On completing the above step, you will find the option to set various options for forecast. Choose the Forecast Length as 2 years and leave the Forecast Model to Automatic as shown in the following screenshot.

forecast 2

单击确定,你将获得如以下截图所示的最终预测结果。

Click OK, and you will get the final forecast result as shown in the following screenshot.

forecast 3

Describe Forecast

通过选择“描述预测”选项,您还可以获得预测模型的详细资料。要使用此选项,请右键单击预测图表,如以下屏幕截图所示。

You can also get minute details of the forecast model by choosing the option Describe Forecast. To get this option, right-click on Forecast diagram as shown in the following screenshot.

forecast 4

Tableau - Trend Lines

趋势线用于预测变量特定趋势的延续。它还有助于通过同时观察两个变量中的趋势来识别两个变量之间的相关性。有许多数学模型用于建立趋势线。Tableau 提供了四个选项。它们分别是线性、对数、指数和多项式。本章仅讨论线性模型。

Trend lines are used to predict the continuation of a certain trend of a variable. It also helps to identify the correlation between two variables by observing the trend in both of them simultaneously. There are many mathematical models for establishing trend lines. Tableau provides four options. They are Linear, Logarithmic, Exponential, and Polynomial. In this chapter, only the linear model is discussed.

Tableau 采用时间维度和度量字段来创建趋势线。

Tableau takes a time dimension and a measure field to create a Trend Line.

Creating a Trend Line

使用 Sample-superstore,找出明年销售额度量值趋势。要实现此目标,请执行以下步骤。

Using the Sample-superstore, find the trend for the value of the measure sales for next year. To achieve this objective, following are the steps.

Step 1 - 将维度订单日期拖到列栏,将度量销售拖到行栏。选择图表类型为折线图。在分析菜单中,转到模型 → 趋势线。单击趋势线将弹出一个选项,显示可添加的不同类型的趋势线。选择线性模型,如下面屏幕截图所示。

Step 1 − Drag the dimension Order date to the Column shelf and the measure Sales to the Rows shelf. Choose the chart type as Line chart. In the Analysis menu, go to model → Trend Line. Clicking on Trend Line pops up an option showing different types of trend lines that can be added. Choose the linear model as shown in the following screenshot.

trend line 1

Step 2 - 完成上述步骤后,你将获得各种趋势线。它还显示字段之间相关性的数学表达式、P 值和 R 平方值。

Step 2 − On completion of the above step, you will get various trend lines. It also shows the mathematical expression for the correlation between the fields, the P-Value and the R-Squared value.

trend line 2

Describe the Trend Line

右键单击图表,然后选择描述趋势线选项以获取趋势线图表の詳細说明。它显示了系数、截距值和方程。这些详细信息还可以复制到剪贴板并在进一步分析中使用。

Right-click on the chart and select the option Describe Trend Line to get a detailed description of the Trend Line chart. It shows the coefficients, intercept value, and the equation. These details can also be copied to the clipboard and used in further analysis.

trend line 3