简体   繁体   中英

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

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. Once you have that value you can easily create the ratio you wanted.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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