Tableau,“至今",“本月",“年" [英] Tableau, Week to Date, Month To Date, Year to Date parameter

查看:136
本文介绍了Tableau,“至今",“本月",“年"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个跨越2年的数据集,并且每天更新一次,创建了一个仪表板以按日期组提供事件视图.我使用日期截断为天/周/月/季度/年创建了一个参数.这是在Tableau中.

我正在尝试获取参数以显示迄今为止的星期,至今的月等等.IE,如果我在12月15日星期三选择了每周视图,那么它将仅显示Sat-Weds数据集中的每周数据(我的周六为Sat-Fri)或每月1月15日至15日之间的每月视图

理想情况下,我希望将其作为下拉菜单的简单参数,我可以将每周至今的工作作为滚动总和在单独的表中每周重新启动,但是为了简便起见,我只需要一个日期组函数即可允许这样做.

任何建议将不胜感激.

欢呼

Pete

解决方案

解决方案分为5部分:

  1. 日期部分参数
  2. 最长日期[最长日期]
  3. 最大日期的动态日期部分[最大动态日期的部分]
  4. 历史日期的动态日期部分[动态日期部分]
  5. 过滤那些日期部分< =最高日期[动态日期-比最高时间还差]

日期部件参数

最长日期

这是您用于数据集以查找最大日期的计算.

  {MAX([订购日期])} 

为了创建一个很好的例子,我将最大日期"设置为一周中,一个月中和一年中的某个特定日期.我将使用2018年6月13日作为我的最大日期".

因此,如果您想跟进,可以使用以下日期作为最长日期.如果需要,您还可以使用

好像我们看到的是当月的所有天< = 13日.

当我们将其更改为星期几"时,我们只会看到星期几< =星期四,即星期四从周六开始的星期三.

现在,让我们计算动态日期部分的销售总额,以更好地为您的示例提供帮助.

将要计算运行总和的度量拖到标签上,然后创建快速表格计算.接下来,我们需要像这样编辑此表计算.

然后,您将看到您的计算按预期进行.

希望这很有帮助.祝你开心!

I have a data set spanning 2 years and is updated daily, created a dashboard to give a view of incidents by date group. I have created a parameter using date trunc for Day/Week/Month/Quarter/Year. This is in Tableau.

I am trying to get the parameter to show a Week to date, Month to date and so on view. IE if on Weds 15th Dec I selected the weekly view, it would only show data for every week in the data set for Sat-Weds (My weeks go Sat-Fri) or the monthly view every month between 1st-15th

Ideally I am wanting this as a simple parameter for a drop down menu, I can do the week to date stuff as a rolling sum restarting every week in a separate table, but for ease I just need a date group function that will allow to do this.

Any suggestions would be appreciated.

Cheers

Pete

解决方案

The solution is 5 parts:

  1. Date Part Parameter
  2. Max date [Max Date]
  3. Dynamic date part of the Max date [Dynamic Date Part Max]
  4. Dynamic date part of the historical dates [Dynamic Date Part]
  5. Filter those date parts <= the Max date [Dynamic Date - Lass than Max]

Date Part Parameter

Max Date

This is the calculation you'd use with your dataset to find the max date.

{ MAX([Order Date]) }

In order to create a good example, I'm going to set my Max date to a specific date the falls in the middle of a week, in the middle of a month and middle of the year. I'm going use June 13th, 2018 as my Max Date.

So, if you want to follow along you can use the below date as your max date. You can also use this data set if you'd like.

DATE(#2018-06-13#)

Dynamic date part of the Max date

DATEPART([Select Date Part], [Max Date])

Dynamic date part of the Historical dates

DATEPART([Select Date Part], [Order Date])

Filter on Historical dates parts <= the Max Date

[Dynamic Date Part] <= [Dynamic Date Part Max]

Now that we have all the pieces we need let's check to make sure they are working as we would expect.

Looks like we're seeing all the days of the month that are <= the 13th.

When we change it to Day of the Week we see only the days of the week <= the 4th day of the week which is Wednesday when the week starts on Saturday.

Now let's calculate the running sum of sales along our dynamic date part to better help you with your example.

Drag the measure you want to calculate the running sum onto the label, then create a quick table calculation. We'll next need to edit this table calculation as so.

You'll then see your calculation working as you would expect.

Hope this was helpful. Happy vizzing!

这篇关于Tableau,“至今",“本月",“年"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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