Jan 19 2022 01:58 PM
I want a formula to lookup a date, establish whats it falls onto using the week ending date, match that against the employee name and return the intersecting value.
For example, I want to see James' potential hours for 8/1/21, which should return 32 (B16). If the date was 04/04/21 then it should return 25.6 for James
The dates in my dataset are by week ending e.g. Sunday 10/1/21 so a date lookup would need to know that 8/1/21 falls under that week and returns the intersecting value against the employee name
I have tried the following xlookup to no avail
=XLOOKUP(B3,A13:A16,XLOOKUP(B4,B12:AW12,B16:AW16,"not found",1,1))
Jan 19 2022 02:19 PM
=IFERROR(INDEX($B$13:$AW$16, XMATCH(B3, $A$13:$A$16), XMATCH(B4, $B$12:$AW$12, 1)), "not found")
Jan 19 2022 02:24 PM
In principle, what you are doing is correct.
= XLOOKUP(
name,
employee,
XLOOKUP(d,wkEnding,hours,"",1)
)
so the problem is in the detail. Maybe looking up a numeric datavalue against a text date.
Jan 19 2022 02:50 PM
Jan 19 2022 02:55 PM
The third argument of your XLOOKUP formula should be an array, but it is XLOOKUP(B4,B12:AW12,B16:AW16,"not found",1,1) which returns a single value, not an array.
Jan 19 2022 03:24 PM
Well spotted. I haven't used a direct cell reference for so long that I tend to see them but not register their content. I simply replaced the reference by a two dimensional array 'hours' and, of course, the formula worked perfectly.
Jan 25 2022 01:39 AM
Jan 25 2022 03:25 AM
Your original formula has two XLOOKUPS:
=XLOOKUP(B3,A13:A16,XLOOKUP(B4,B12:AW12,B16:AW16,"not found",1,1))
The first (outer) XLOOKUP has arguments:
1. Lookup value: B3
2. Lookup array: A13:A16
3. Return array: XLOOKUP(B4,B12:AW12,B16:AW16,"not found",1,1)
The return array argument is an XLOOKUP formula that returns a single value, not an array.