根据 Google 工作表中 sheet 时间的数据计算员工的工作时间和休息时间

Calculate duration of work and break period of employees from time sheet data in Google Sheets

有两个 Google sheet timesheet(数据附加自 RFID reader) https://docs.google.com/spreadsheets/d/1T_ZbPub9CV_-S5Ve5OxtlPoGfvV8uXkxxoKnUGBuXPo/edit?usp=sharing 想知道一个月内员工的工作时间和休息时间。 (员工一天可以多次休息) 对于给定的一天,总是第一拳是 IN,第二拳是 OUT,这将给出他工作的持续时间。剩下的就是休息时间

结果sheet(月出勤率) https://docs.google.com/spreadsheets/d/1IWu1eJCtG3LQQYfF2N5Hd02rZ2t3GfgbjOoYQbQuQFk/edit?usp=sharing

由于数据是一列不知道如何实现给定日期的迭代。

首先,您需要做一些准备工作。查看列 J:O:

那么你可以做简单的 HLOOKUP:

=ARRAYFORMULA(IFERROR(HLOOKUP(A24:24, QUERY(QUERY({Sheet2!J1:O}, 
 "select Col1,day(Col1),sum(Col5),sum(Col6),Col4 
  where month(Col1)+1="&B23&" 
  group by Col1,Col4 
  format Col1'd'", 0), 
 "select Col5,"&IF(D23="Break", "sum(Col4)", "sum(Col3)")&" 
  where Col5 is not null
  group by Col5
  pivot Col2
  label Col5'Employee names'", 1), ROW(A2:A20), 0)))

spreadsheet demo


更新:

要修复缺失的打孔,您可以添加一个检查:

={"punch-out check"; 
 ARRAYFORMULA(IFNA(VLOOKUP(A2:A&C2:C, QUERY(QUERY({A2:A&C2:C, 
 COUNTIFS(A2:A&C2:C, A2:A&C2:C, ROW(A2:A), "<="&ROW(A2:A))},
 "select Col1,sum(Col2) group by Col1"),
 "where not Col2 >1 offset 1", 0), 2, 0)))}


那么公式就是:

=ARRAYFORMULA({"Date","Start", "End", "Name";
 {ARRAY_CONSTRAIN(FILTER(SORT(FILTER({timesheet!A2:B, timesheet!E2:E}, timesheet!F2:F<>1), 1, 1, 3, 1, 2, 1), 
 MOD(ROW(INDIRECT("timesheet!A1:A"&ROWS(timesheet!A2:A)-COUNTIF(timesheet!F2:F, 1))), 2)), 
 ROWS(timesheet!A2:A)-COUNTIF(timesheet!F2:F, 1), 2)}, 
 QUERY(FILTER(SORT(FILTER({timesheet!A2:B, timesheet!E2:E}, timesheet!F2:F<>1), 1, 1, 3, 1, 2, 1), 
 MOD(ROW(INDIRECT("timesheet!A2:A"&ROWS(timesheet!A2:A)-COUNTIF(timesheet!F2:F, 1)+1)), 2)), "select Col2, Col3", 0)})


仪表板会像这样列出它:

={"Didn't punched out"; FILTER(timesheet!E2:E, timesheet!A2:A=C2, timesheet!F2:F=1)}

我想你可以做到

Sum of even times - Sum of odd times

=ArrayFormula(sumif(iferror(iseven(rank(if((timesheet!$E2:$E=$A3)*(timesheet!$A2:$A=date(2019,$B,O)),timesheet!$B2:$B),if((timesheet!$E2:$E=$A3)*(timesheet!$A2:$A=date(2019,$B,O)),timesheet!$B2:$B),1)),false),true,timesheet!$B2:$B)-
sumif(iferror(isodd(rank(if((timesheet!$E2:$E=$A3)*(timesheet!$A2:$A=date(2019,$B,O)),timesheet!$B2:$B),if((timesheet!$E2:$E=$A3)*(timesheet!$A2:$A=date(2019,$B,O)),timesheet!$B2:$B),1)),false),true,timesheet!$B2:$B))

整体情况如下 sheet:

编辑

检查出拳次数 in/out 是否为偶数:

=ArrayFormula(if(isodd(countifs(timesheet!$E:$E,$A3,timesheet!$A:$A,date(2019,$B,O))),"Error",sumif(iferror(iseven(rank(if((timesheet!$E:$E=$A3)*(timesheet!$A:$A=date(2019,$B,O)),timesheet!$B:$B),if((timesheet!$E:$E=$A3)*(timesheet!$A:$A=date(2019,$B,O)),timesheet!$B:$B),1)),false),true,timesheet!$B:$B)-
sumif(iferror(isodd(rank(if((timesheet!$E:$E=$A3)*(timesheet!$A:$A=date(2019,$B,O)),timesheet!$B:$B),if((timesheet!$E:$E=$A3)*(timesheet!$A:$A=date(2019,$B,O)),timesheet!$B:$B),1)),false),true,timesheet!$B:$B)))