计算列 [英] Calculated Columns

查看:83
本文介绍了计算列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HI,


我正在尝试对两个计算列进行一些计算,但没有任何运气使其正常工作。 


非常感谢任何帮助。


以下是专栏:


第一个计算列:工作日内请求的总转弯时间

-创建日期与完成或拒绝数据之间的时间长度



时间应为工作日和日:小时基于8小时工作日和每周5天。应该从上午7点到下午6点开始生成
并完成或拒绝数据=日期数据类型


第二个计算列:总转弯时间行数工作日数
创建日期与完成或拒绝数据之间的时间长度除以行数#


时间应该在工作日和日:小时基于8小时工作日和每周5天。应该从早上7点到下午6点左右。


行数=数据数据类型


创建日期,数据完成或拒绝=日期数据类型



谢谢!

解决方案


您可以在
中引用我的回复
this thread
要求类似的要求。


使用计算列公式计算两者之间的工时两次不包括周末。


(注意:更改[ StartDate]和[EndDate]到列名。)


1。创建一个名为"workdays"的计算列。使用以下公式获取两次工作日(不包括周末)。


= IF(AND((WEEKDAY([结束日期],2))≤(WEEKDAY([开始日期],2)),((WEEKDAY([开始日期],2)) - (WEEKDAY([结束日期],2)))→1),(((DATEDIF([开始日期],[结束日期]," d")+ 1)) - (FLOOR((DATEDIF([开始日期],[结束日期]," d")+ 1)/ 7,1)* 2)-2),(((DATEDIF([开始日期],[结束日期]," d")+ 1)) - (FLOOR((DATEDIF([开始日期] ,[EndDate],"D")+ 1)/ 7,1)* 2)))


2。计算两次之间的工作时间。


如果workdays等于1,表示两次是在同一天。


上午7点到下午6点之间有11个小时。我想工作日有休息时间。例如,工作时间从上午7点到上午10点,休息3小时,然后从下午1点到下午6点工作。


如果你用休息时间(早上7点到下午6点)计算时间,则有11个小时。


两次工作时间= HOUR([EndDate]) - HOUR([StartDate])


如果您需要排除休息时间(例如早上7点至上午10点,下午1点 - 下午6点。


工作时间两次=
IF(AND(7< = HOUR([StartDate])< = 10,13< = HOUR([EndDate])< ; = 18),HOUR([EndDate]) - HOUR([StartDate]) - 3,HOUR([EndDate]) - HOUR([StartDate]))


如果工作ays大于1,这意味着两次是在不同的日子。


如果你计算休息时间(上午7点到下午6点)的时间,则有11个小时。


< p style ="margin-bottom:12.0pt; background:white"> 两次工作时间=([工作日] -2)* 11 +(18小时([StartDate]))+(HOUR([EndDate]) -7)


如果你计算没有休息时间的时间(例如早上7点 - 上午10点,下午1点 - 下午6点)。


(18-HOUR([StartDate]))> =(18-13),表示StartDate有休息时间(3小时)。


(HOUR([EndDate]) - 7)> =(10-7),表示StartDate有休息时间(3小时)。


两次工作时间=([工作日] -2)* 8 + IF(18小时([StartDate])> = 5,18-HOUR ([StartDate]) - 3,18小时([StartDate]))+ IF(HOUR([EndDate])> = 3,HOUR([EndDate]) - 7-3,HOUR([EndDate]) - 7 )


然后,分别计算分钟部分。使用

MINUTE函数
获取时间值的分钟数(忽略小时数)。


MINUTE([EndDate]) - MINUTE([StartDate])


如果结果大于或等于0,则表示两次之间的分钟数超过60。


两次之间的时间(小时和分钟)= [workhours]&" h"&(MINUTE([EndDate]) - MINUTE([StartDate] ))


如果结果小于0,则表示两次之间的分钟数超过60。


两次之间的时间(小时和分钟)= [workhours] -1&" h"&(60+(MINUTE([EndDate]) - MINUTE ([StartDate])))


摘要:使用公式获得两次工作时间和分钟。


IF((MINUTE([EndDate]) - MINUTE([StartDate]))> = 0,[workhours]&" h"&( MINUTE([EndDate]) - MINUTE([StartDate])),[workhours] -1&" h"&(60+(MINUTE([EndDate]) - MINUTE([StartDate]))))


最好的问候,


Linda Zhang


HI,

I am trying to do some calculations on two calculated columns but haven't had any luck to make it work. 

Any help will be very appreciated.

Here are the columns:

First calculated column: Total turn time of request in working days
-Length of time between date created and data completed or rejected

Time should be in working days and day:hr based on 8 hour work day and 5 days a week. Should go from 7AM to 6PM
created and data completed or rejected = date data types

Second calculated column: Total turn time by # of lines working days
Length of time between date created and data completed or rejected divided by the # of lines

Time should be in working days and day:hr based on 8 hour work day and 5 days a week. Should go from 7AM to 6PM

# of lines = number data type

date created and data completed or rejected = date data types

Thank you!

解决方案

Hi,

You can refer to my replies in this thread which asks the similar requirement.

Use calculated column formula to calculate that work hours between two times excluding weekends.

(Note: Change [StartDate] and [EndDate] to your column names.)

1. Create a calculated column named "workdays". Get the workdays (exclude weekends) between two times using the following formula.

=IF(AND((WEEKDAY([EndDate],2))<(WEEKDAY([StartDate],2)),((WEEKDAY([StartDate],2))-(WEEKDAY([EndDate],2)))>1),(((DATEDIF([StartDate],[EndDate],"D")+1))-(FLOOR((DATEDIF([StartDate],[EndDate],"D")+1)/7,1)*2)-2),(((DATEDIF([StartDate],[EndDate],"D")+1))-(FLOOR((DATEDIF([StartDate],[EndDate],"D")+1)/7,1)*2)))

2. Calculate the work hours between two times.

If the workdays is equal to 1, it means the two times are on the same day.

There are 11 hours between 7 am and 6 pm. I suppose there is break time in work day. For example, work from 7 am to 10 am, break 3 hours, then work from 1 pm to 6 pm.

If you calculate the time with break time (7 am – 6pm), then there are 11 hours.

Work hours between two times = HOUR([EndDate])-HOUR([StartDate])

If you need to exclude the break hours (e.g. 7 am – 10 am, 1 pm – 6 pm).

Work hours between two times = IF(AND(7<=HOUR([StartDate])<=10,13<=HOUR([EndDate])<=18),HOUR([EndDate])-HOUR([StartDate])-3,HOUR([EndDate])-HOUR([StartDate]))

If the workdays is greater than 1, it means the two times are on the different days.

If you calculate the time with break time (7 am – 6pm), then there are 11 hours.

Work hours between two times = ([workdays]-2)*11+(18-HOUR([StartDate]))+(HOUR([EndDate])-7)

If you calculate the time without break time (e.g. 7 am – 10 am, 1 pm – 6 pm).

(18-HOUR([StartDate])) >= (18-13), means the StartDate has break time (3 hours).

(HOUR([EndDate])-7) >= (10-7), means the StartDate has break time (3 hours).

Work hours between two times = ([workdays]-2)*8+IF(18-HOUR([StartDate])>=5,18-HOUR([StartDate])-3, 18-HOUR([StartDate]))+IF(HOUR([EndDate])>=3,HOUR([EndDate])-7-3, HOUR([EndDate])-7)

Then, calculate the minute part separately. Use MINUTE function to get the minutes of the time value (ignoring hours).

MINUTE([EndDate])-MINUTE([StartDate])

If the result is greater than or equal to 0, it means minutes between two times exceed 60.

Times (hours and minutes) between two times = [workhours]&"h"&(MINUTE([EndDate])-MINUTE([StartDate]))

If the result is less than 0, it means minutes between two times exceed 60.

Times (hours and minutes) between two times = [workhours]-1&"h"&(60+(MINUTE([EndDate])-MINUTE([StartDate])))

Summary: using the formula to get the works hours and minutes between two times.

IF((MINUTE([EndDate])-MINUTE([StartDate]))>=0,[workhours]&"h"&(MINUTE([EndDate])-MINUTE([StartDate])), [workhours]-1&"h"&(60+(MINUTE([EndDate])-MINUTE([StartDate]))))

Best Regards,

Linda Zhang


这篇关于计算列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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