Tableau-不同日期范围的过滤器/参数 [英] Tableau - Filter/Parameter For Different Date Ranges

查看:908
本文介绍了Tableau-不同日期范围的过滤器/参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为Tableau中的不同日期范围设置过滤器或参数,例如:

I am trying to set up a filter or parameter for different date ranges in Tableau, such as:

  1. 上周
  2. 之前的4周
  3. 以前的8周

基于数据库中的最新数据.这可能吗?

based on the most recent data in the database. Is this possible?

修改: 我应该在这里更加清楚.

Edit: I should have been more clear here.

是否可以仅在过滤器中使用这些选项,并使其基于数据库中的最大日期?

Is it possible to only have these options in the filter and have it based on the maximum date in the database?

推荐答案

更新

根据您的评论和更新的问题,尽管不是那么简单,但是您可以按自己的意愿进行操作.

Update

Based on your comment and updated question, you can do it as you intend, though it isn't as straight-forward.

注意:我使用随机数据集非常快地完成了此操作,因此对您使用数据集进行全面测试非常重要.

NOTE: I did this very quickly and with a random data set, so it will be important for you to test this thoroughly with your data set.

步骤:

  1. 创建一个参数控件,用户将使用该控件来更改选定的日期范围.我将其创建为具有可直接在计算后的值(简单转换后)中使用的值的字符串列表:

  1. 创建一个计算字段,该字段将用作引用参数控件选择的过滤器.它进行测试以查看视图中的最大日期与任何给定行的日期之间的差(以周为单位)是否小于参数的值.

计算:INT([Date Filter Parameter]) > DATEDIFF("week",ATTR([Date Field]),WINDOW_MAX(MAX([Date Field])))

  1. 将计算所得的字段放在过滤器框中,并将其设置为True.

您将能够像这样过滤数据:

You will be able to filter your data like so:

是的-它内置于Tableau中.

Yup - that is built into Tableau.

将日期添加到过滤器中,然后选择相对日期"选项:

Add your date to the filter and select the "Relative Date" option:

您可以设置默认值-用户以后可以更改它们:

You can set the defaults - users can change these later:

然后只是显示过滤器":

Then just "Show Filter":

这篇关于Tableau-不同日期范围的过滤器/参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆