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.

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

创建计算字段


连接到 Sample superstore 后,转到 Analysis 菜单并单击“Create Calculated Field”,如下面的屏幕截图所示。

Create calculation

计算编辑器


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

date calc 1

创建公式


现在,找出销售量以及销售日期与 21 月之间的差异 st 2009 年 3 月。为此,创建如下屏幕截图所示的公式。

date calc 2

使用计算字段


现在要查看实际创建的字段,你可以将其拖到“行”架子上,并将“销售”字段拖到“列”架子上。还要用月份拖动船日期。以下屏幕截图显示了销售值。

date calc 3