[英]Using a single Calculated field , can I get the number of weekdays calculated from the current month in Tableau?
I have a requirement to do % of (Workdays till date) / (Total Workdays of the month). 我需要执行(截至日期的工作日)/(每月的总工作日)的百分比。 How can I create a "Calculated field" for this logic.
如何为该逻辑创建“计算字段”。 I don't need to consider holidays or any sort.
我不需要考虑假期或任何形式的假期。 Any help is highly appreciated.
非常感谢您的帮助。
A quick google search turned up this: http://kb.tableau.com/articles/knowledgebase/calculating-the-number-of-business-days 谷歌快速搜索发现了这一点: http : //kb.tableau.com/articles/knowledgebase/calculating-the-number-of-business-days
In the Calculated Field dialog box, do the following and then click OK: Name the calculated field.
在“计算字段”对话框中,执行以下操作,然后单击“确定”:命名计算字段。 In the example workbook, the calculated field is named Number of Weekdays.
在示例工作簿中,计算出的字段名为“工作日数”。 In the formula field, create a calculated field similar to the following:
在公式字段中,创建一个类似于以下内容的计算字段:
DATEDIFF("weekday", [Start Date], [End Date]) - 2 * (DATEPART('week', [End Date]) -DATEPART('week', [Start Date])) + (IF DATENAME('weekday',[End Date]) = 'Saturday' OR DATENAME('weekday',[Start Date]) = 'Sunday' THEN 0 ELSE 1 END)
In your example you take the difference between the first and the last of a month and calculate the working days by subtracting 2 * [number of weeks]
for the weekends. 在您的示例中,您采用一个月的第一天与最后一个月之间的差,并通过减去周末的
2 * [number of weeks]
来计算工作日。 Once you have that value you can easily create the ratio you wanted. 一旦获得该值,就可以轻松创建所需的比率。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.