Thanks Ali.
A full day of playing around with this sadly hasn't resulted in a positive outcome, so I'll see if I can provide the steps you've mentioned above for how I arrived at the manual numbers.
1. I counted the number of days in the Request date range for each employee, where these fell within the defined date range (as specified in the Attendances tab, which is basically the whole of Jan 2024). I then subtracted any dates that fell on a weekend, or were a public holiday. As below screenshot.
Attachment 871093
2. The sum also took into account whether a duration was specified (which are only shown if these are for a period of less than one whole day).
3. The total sum for each employee, I then carried over to the Attendances tab. And that was it.
In trying to find a solution for this, I had thought about identifying the dates from the defined range on the Attendances tab, and omitting the weekends and public holidays from this, to create an array of working days only over the defined range, which I was able to do. This looked like the following:
=LET(
dateRng, SEQUENCE(C5-B5+1,1,B5),
weekDayRng, dateRng - 1,
filteredWeekdays, FILTER(dateRng, WEEKDAY(weekDayRng)<=5),
excludedPHs, Tbl_PHs[Date],
FILTER(filteredWeekdays, NOT(ISNUMBER(MATCH(filteredWeekdays, excludedPHs, 0)))))
I then tried to get an array of all dates for a particular employee from the Absences table, that I could then use to look up against the previous data set, and count where there was an overlap of dates / matching dates. I got as far as the following, but this returned a #CODE! error. I think maybe it didn't like the SEQUENCE function being nested within the LAMDA.
=LET(
absTbl, Tbl_Abs,
empRng, Tbl_Abs[Full Name],
empName, "Ian Marshall",
fromDates, FILTER(INDEX(absTbl, , 3), empRng=empName),
toDates, FILTER(INDEX(absTbl, , 4), empRng=empName),
allDates, MAP(fromDates, toDates, LAMBDA(f,t, SEQUENCE(t - f + 1, 1, f))),
VSTACK(allDates)
)
I was then planning to apply something along the lines of =SUM(COUNTIF(array 1, array 2)).
All of this I would need to incorporate into a single formula, and also I still needed to figure out how this would capture where there were absences for part days only, which this wouldn't at present.
I imagine there is probably a better way of doing this, and I may potentially just be confusing things by providing my initial thoughts on this, but thought I would share anyway, just in case this helped at all.
Thanks again.
Skins
Bookmarks