- 举个栗子!Tableau 技巧(102):教你制作新年日历
- VMware 搭建 Tableau Server for Lin
- 举个栗子!Tableau 技巧(100):吸睛又直观的 四瓣花图
- 举个栗子!Tableau技巧(4):如何做空心饼图(环形图)
- 举个栗子!Tableau技巧(28):教你制作有趣的bump c
- 举个栗子!Tableau技巧(9):巧妙制作混合地图
- 举个栗子!Tableau 技巧(212):如何制作矩形散点图
- 举个栗子!Tableau技巧(39):巧妙制作分类桑基图
- 举个栗子!Tableau技巧(19):教你轻松迁移License
- 举个栗子!Tableau 技巧(200):教你取消单击高亮
新年新气象!我们就来应个景儿,教大家如何在 Tableau 中实现日历。来吧,跟我学做一个 2019 年数据日历!


本期《举个栗子》,阿达要给大家分享的 Tableau 技巧是:教你制作新年日历。
————————————————————————————》》
为方便学习,我们采用一份简单的 Excel 数据:2019年全年日历数据

具体步骤如下:
STEP 1:连接数据源 —————————————》》
点击数据菜单栏下的新建数据源,选择更多,在弹出的文件选项框中点击日期数据.csv,点击打开。

STEP 2:创建台头工作表 —————————————》》
- 新建工作表,命名为台头。

右键点击日期,选择创建计算字段。这里,创建计算字段年份,用于提取日期中的年:
DATE(DATEPARSE ( "yyyy", STR(YEAR([日期])) ))

然后,更改刚刚创建的计算字段年份的数据类型为日期。

然后,将年份维度拖动到文本标记中。

点击标记卡中的文本,对齐方式选择中部居中。

然后,设置文本格式(如下图):

右键文本标记年份,将阴影格式中默认值设置为无:

STEP 3:创建月份工作表 —————————————》》
- 创建新的工作表,命名为月份。
接着,创建计算字段月份%3,并将计算字段月份%3 拖到维度。
MONTH([日期])%3

将维度中的计算字段月份%3 拖到列。然后,右键月份%3 点击排序,选择手动排序,将 0 置于最下层。

将日期维度拖动到行,右键日期胶囊,选择离散、季度。

将日期维度拖动到文本标记框内,右键选择设置格式:离散、月。右键月(日期),将区格式中的日期格式设置为数字。

然后,点击阴影下拉到行分级,将区格式设置为无。

最后,编辑标签的字体和大小,调整后的效果如下:

STEP 4:创建日历工作表 —————————————》》
- 创建新的工作表,命名为日历。
新建计算字段周索引,并将计算字段周索引拖到维度。
DATEPART('week',[日期])
-
{FIXED MONTH([日期]):MIN(DATEPART('week',[日期]))}

新建计算字段天:
IIF(ISNULL([日期 (节假日)]),DATENAME('day',[日期]),[节日])

将计算字段月份%3 拖到列中,并设置排序为手动,将0置于最下层(方法同上)。
将日期拖到列中,选择离散、工作日。
将日期拖到行中,选择离散、季度。
将计算字段周索引拖到行中。
将计算字段天拖到标记中的标签。
将日期拖到标记中的颜色,设置为连续的天。将标记从自动更改为方形。点击颜色选框设置不透明度为80%。
右键工作日(日期),设置格式,将默认值中的日期格式改为第一个字母,并将字体设置为白色。如下图:

然后,调整整体格式(如下图):

STEP 5:创建日范围工作表 —————————————》》
- 创建新的工作表,命名为日范围。
将日期拖动到列,选择属性为连续、天。
将日期拖动到颜色,选择属性为连续、天。
将标记设置为条形图。
右键编辑轴,范围选择固定:2019年1月1日- 2019年12月31日。

然后,调整格式(如下图):

STEP 6:创建日历板仪表板 —————————————》》
- 新建仪表板,命名为日历板。
将对象中的水平拖动到面板中,并设置为固定大小712*712。

再拖入一个垂直对象到面板,将工作表日范围拖入其中,在右侧布局中将外边距设置为0;右键面板中的日范围,去除标题显示后,勾选固定高度并编辑高度为59,最后选择适合整个视图。

将工作表月份拖至下方后,右键隐藏标题。

排版方式改选为浮动后,将工作表日历拖到面板中,右键隐藏标题,并在右侧布局中将背景色设置为黑色(透明度70%),坐标位置如下图:

将工作表台头拖动到面板,隐藏标题,选择上排中间的位置放置即可。
如此,我们就完成了 2019 年日历的制作啦!

今天的 Tableau 技巧,你 Get 到了吗?赶快试试看吧!
下一期《举个栗子》,再会~

文章部分信息来源于网络,如有侵权请告知!
网友评论