tableau 中日期范围过滤器的默认范围 [英] Default range for date range filter in tableau

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

问题描述

我想在日期过滤器上设置默认范围以显示过去 10 天 - 所以基本上查看数据中的 lastDate(最大日期),并且仅在过去 10 天(maxDate - 10)进行默认过滤

I want to set the default range on a date filter to show me the last 10 days - so basically looking at the lastDate (max date) in the data and default filtering only on the last 10 days (maxDate - 10)

现在的样子:

我仍然希望看到仪表板上的整个范围栏,并让用户能够根据需要修改所选范围.maxDate 在每次数据刷新后都会发生变化,因此它必须是应用于过滤器的某种条件.

I still would want to the see the entire range bar on the dashboard and give the user the ability to modify the selected range if he wants to. The maxDate changes after every data refresh so it has to be some sort of a condition that is applied to the filter.

我希望它的外观(默认情况下每次刷新数据后 - 新日期到来):

How I want it to look (by default after every refresh of data - new dates coming in):

关于如何做到这一点的任何建议?我知道我可以使用相对日期并显示过去 10 天的数据,但这会修改​​过滤器并创建我不想要的下拉列表.

Any suggestions on how this can be done? I know I can use the relative date and show the data for last 10 days but that would modify the filter and create a drop down which I don't want.

欢迎提出任何建议!

推荐答案

一种简单的方法可以满足您的大部分需求:

One simple approach that does most of what you want is the following:

  1. 创建一个整数值参数,范围从 1 到某个最大值你选择,说 100.称之为 num_days.

  1. Create an integer valued parameter with a range from 1 to some max you choose, say 100. Call it say num_days.

将仪表板上的参数控件显示为滑块,并给出它是一个不错的标题,例如要显示的天数"

Show the parameter control on your dashboard as a slider, and give it a nice title like "Number of days to display"

创建一个名为 Within_Day_Range 的布尔计算字段,定义为:

Create a boolean calculated field called Within_Day_Range defined as:

datediff('minute', [My_Date_Field], now()) <[num_days] * 24 * 60

将 Within_Day_Range 放在过滤器架上并选择值 true.

Put Within_Day_Range on the filter shelf and select the value true.

这让用户可以轻松地选择要包含过去的天数,并以分钟为粒度(即过去两天实际上是指过去 48 小时,而不是从昨天午夜开始).如果您想要不同的行为,请调整计算字段.

This lets the user easily select how many days in the past to include, and works to the granularity of minutes (i.e. the last two days really means the last 48 hours, not starting at midnight yesterday). Adjust the calculated field if you want different behavior.

到目前为止描述的这种方法的主要缺点是它不会显示数据库中可能的最早日期,因为它被过滤掉了.快速过滤器执行初始查询以获取边界,这会产生性能成本 - 因此使用此处描述的方法可以避免该查询并因此加载更快.

The main drawback of this approach as described so far is that it doesn't display the earliest date possible in the database because that is filtered out. Quick filters do an initial query to get the bounds, which has a performance cost -- so using the approach described here can avoid that query and thus load faster.

如果您真的需要仪表盘上的信息,您可以创建一个不同的工作表来获取 min([My_Date_Field]) 并将其显示在您的参数控件附近.

If you really need that information on your dashboard, you could create a different worksheet to get just the min([My_Date_Field]) and display that near your parameter control.

这篇关于tableau 中日期范围过滤器的默认范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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