简体   繁体   English

Tableau - 将过滤器的默认值设置为上个月

[英]Tableau - Set Default value for filter as previous month

Is there a way to set dynamic default values for filters in Tableau?有没有办法在 Tableau 中为筛选器设置动态默认值?

Example: For Date filter set the value to previous month.示例:对于日期过滤器,将值设置为上个月。

I know that default value for filters can be set as selecting a specific value before publishing the workbook.我知道过滤器的默认值可以设置为在发布工作簿之前选择特定值。

There is an option to set default value to current date but I need it for previous month.有一个选项可以将默认值设置为当前日期,但我上个月需要它。

Let me know if need more information.如果需要更多信息,请告诉我。

You most likely need a filter using a calculated field.您很可能需要使用计算字段的过滤器。 This can be achieved either by a fixed LOD expression or by using a table calculation.这可以通过固定的 LOD 表达式或使用表计算来实现。

My recommendation would be to filter the data at the extract level.我的建议是在提取级别过滤数据。 So you would bring into Tableau only the data you need to work with.因此,您只需将需要处理的数据引入 Tableau。

I wrote an article where we bumped into a similar issue: https://canonicalized.com/tableau-dashboard-performance-optimization-case-study/?section=extracts (search for "Step 1: filter incomplete months" if you can't find it)我写了一篇文章,我们遇到了类似的问题: https : //canonicalized.com/tableau-dashboard-performance-optimization-case-study/?section=extracts (如果可以, 搜索“步骤 1:过滤不完整的月份”没找到)

This is the LOD expression I used to filter the data for the latest month if it's incomplete:如果最近一个月的数据不完整,这是我用来过滤数据的 LOD 表达式:

{FIXED MONTH([Date]), YEAR([Date]): MAX([Date]) < MAX(datetrunc('month',dateadd('month',1,[Date]))-1)}

Use a relative date filter.使用相对日期过滤器。 Right-click on the date dimension field and drag it onto the Filter shelf.右键单击日期维度字段并将其拖到过滤器架上。 Then choose the Relative Date option.然后选择相对日期选项。 This opens the filtering dialog box, choose Previous month on the Months tab.这将打开过滤对话框,在月份选项卡上选择上个月。 Then, when you publish the workbook, the default value will be what you saved in the workbook.然后,当您发布工作簿时,默认值将是您在工作簿中保存的内容。

See the online help document for images and detailed step-by-step instructions.有关图像和详细的分步说明,请参阅联机帮助文档。 https://onlinehelp.tableau.com/current/pro/desktop/en-us/qs_relative_dates.html https://onlinehelp.tableau.com/current/pro/desktop/en-us/qs_relative_dates.html

We can have this with Parameter and with one calculated field.我们可以使用参数和一个计算字段来实现这一点。

1.Create a Parameter using Date column. 1.使用日期列创建一个参数。 Create parameter创建参数

2.Create Calculated field – When you open the workbook ,default it will be set to prior month (Based on your requirement you can change the formula to previous month of last year) 2.创建计算字段 - 当您打开工作簿时,默认设置为上个月(根据您的要求,您可以将公式更改为去年的上个月)

{ FIXED : MAX(DATEADD('month',-1,[ Snapshot Date]))} Calculated field { FIXED : MAX(DATEADD('month',-1,[ Snapshot Date]))}计算字段

3.Call this calculated field in Parameter – Value when workbook Opens :(Prior Month-Cal). 3.在参数 - 工作簿打开时的值中调用此计算字段:(Prior Month-Cal)。 add as current value添加为当前值

4.Use parameter to filter the months (list of months and also default it will be prior month) Filter Prompt looks like 4.使用参数过滤月份(月份列表,也默认是上个月)过滤提示看起来像

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM