上午8点前算前一天的夜班,通用公式:
- =LET(t,FILTER(产线停线明细!A$3:F$11,(产线停线明细!B$3:B$11=B4)*(产线停线明细!A$3:A$11=C$1)),r,TAKE(t,,1),s,DROP(TAKE(t,,-2),,-1),e,TAKE(t,,-1),data,HSTACK(r+N(s<8/24)+s,r+N(e<8/24)+e),sortedData,SORT(data,1),minData,INDEX(sortedData,1,1),sortedInterval,BYROW(sortedData,LAMBDA(r,TEXTJOIN(",",,r))),interval,REDUCE(TEXTJOIN(",",,minData,minData),sortedInterval,LAMBDA(acc,a,LET(theInterval,TEXTAFTER(acc,";",-1,,1),theIntervalEnd,--TEXTAFTER(theInterval,","),curBegin,--TEXTBEFORE(a,","),curEnd,--TEXTAFTER(a,","),IF(theIntervalEnd>=curBegin,TEXTBEFORE(acc,",",-1)&","&MAX(theIntervalEnd,curEnd),acc&";"&a)))),Result,TEXTSPLIT(interval,",",";"),Ra,HSTACK(VALUE(Result)),Rn,SUM(BYROW(Ra,LAMBDA(x,SUM(x*{-1,1})))),IFERROR(Rn*24,""))
复制代码 |