Last active
October 30, 2023 22:17
-
-
Save sblom/2a29b8bf59bdb74700b229b3692fc53e to your computer and use it in GitHub Desktop.
Native Excel array function to take a horizontal array of clock-in/clock-out times and return total hours
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=LET(MakeAcc,LAMBDA(item1,item2,MAKEARRAY(2,1,LAMBDA(row,col,IF(row=1,item1,item2)))), | |
LAMBDA(arr,INDEX(REDUCE({0;-1},FILTER(arr,MAP(arr,LAMBDA(x,ISNUMBER(x))),{0}),LAMBDA(accum,time, | |
LET(total,INDEX(accum,1),start,INDEX(accum,2), | |
IF(start<>-1, | |
MakeAcc(total+(time-start)*24,-1), | |
MakeAcc(total,time) | |
) | |
))),1))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment