如何计算法定假日的工资小时数

huangapple go评论66阅读模式
英文:

How to calculate public holidays payable hours

问题

我正在尝试编写一个Excel公式,用于将每个日期行上的信息分类为公共假期(PH)、周末(WE)或工作日(WD)。公共假期应该无论它们落在哪一天都显示为PH。只有在它们不是公共假期时,才应将日期分类为WE或WD。

这是示例数据集。

我还需要编写一个公式,在列F(PH Payable hours)中插入小时,如果以下条件都满足:1)它是公共假期;(2)员工在过去的4个类似日期中至少工作了3天。插入的小时数必须是前几天的平均值。

例如:如果公共假期是星期一,则参考前3或4个星期一的工作小时数。

这是我查找公共假期的一个查找表之一。

我已经编写了这个公式,但无法在“日期类别”列中填充PH。

=IF(COUNTIF(H52:I57, B54) > 0, "PH", IF(WEEKDAY(B54, 2) > 5, "WE", "WD"))

希望这有所帮助。

英文:

I am trying to write an excel formula that categorises the information on each date row as being a public holiday (PH), weekend (WE) or weekday (WD). Public holidays should display as PH regardless of the day they fall on. Days should only be categorised as WE or WD if they are not public holidays.

Here is the sample dataset.

如何计算法定假日的工资小时数

I also need to write a formula to insert hours into column F(PH Payable hours) if 1) It is a Public holiday AND (2) the employee has worked at least 3 out of the last 4 like days. The number of hours inserted must be the average of the prior like days.

For an example : If the Public holiday falls on a Monday refer to hours worked on the previous 3 or 4 Mondays.

This is one of my look up table to find out PH

如何计算法定假日的工资小时数

I have written this formula but unable to populate PH in "Date category" column

=IF(COUNTIF(H52:I57, B54) > 0, "PH", IF(WEEKDAY(B54, 2) > 5, "WE", "WD"))

Any help would be apprecaited.

答案1

得分: 2

(1) 你的公式是正确的,只需要加入锚点,以便你可以拖动复制它:

=IF(COUNTIF(H$2:I$7, A2) > 0, "PH", IF(WEEKDAY(A2, 2) > 5, "WE", "WD"))

(2) 如果你使用的是Excel 365,你可以筛选数据,只包括与当前工作日相同的日期,早于当前日期且本身是工作日的日期,然后计算最后四天(或只有三天如果只工作了3/4天)的平均值:

=IFERROR( LET(range,A$2:E$14, Date,A$2:A$14, class,E$2:E$14, prevDays,FILTER(range,(WEEKDAY(Date)=WEEKDAY(A2))*(Date<A2)*(class="WD")), last4,CHOOSECOLS(TAKE(SORT(prevDays,1,-1),4),3), worked,SUM(--(last4>0)), IF(worked>=3,AVERAGE(last4),"")), "")

英文:

(1) Your formula is OK, just need to put anchors in so you can copy it down:

=IF(COUNTIF(H$2:I$7, A2) &gt; 0, &quot;PH&quot;, IF(WEEKDAY(A2, 2) &gt; 5, &quot;WE&quot;, &quot;WD&quot;))

(2) If you have Excel 365, you can filter the data to include only days which fall on the same weekday, are earlier than the current day and are themselves working days then average the last four ( or three if only 3/4 have been worked):

=IFERROR(
LET(range,A$2:E$14,
Date,A$2:A$14,
class,E$2:E$14,
prevDays,FILTER(range,(WEEKDAY(Date)=WEEKDAY(A2))*(Date&lt;A2)*(class=&quot;WD&quot;)),
last4,CHOOSECOLS(TAKE(SORT(prevDays,1,-1),4),3),
worked,SUM(--(last4&gt;0)),
IF(worked&gt;=3,AVERAGE(last4),&quot;&quot;)),
&quot;&quot;)

如何计算法定假日的工资小时数

huangapple
  • 本文由 发表于 2023年5月10日 13:22:23
  • 转载请务必保留本文链接:https://go.coder-hub.com/76215136.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定