The table below shows a list of employees and number of hours they have worked in that week. I am trying to come up with formula that would return the total number of hours worked per employee per month (sum the weekly numbers) to fill in the lower table. I have tried combining the XLOOKUP and SUMIFS formula but so far no luck. Does anyone have any tips by chance?
Resource Name |
Resource Level |
7/22/2024 |
7/29/2024 |
8/5/2024 |
8/12/2024 |
8/19/2024 |
8/26/2024 |
9/2/2024 |
9/9/2024 |
Rob |
Manager |
40 |
20 |
37 |
29 |
23 |
31 |
33 |
32 |
Tom |
Analyst |
30 |
25 |
26 |
27 |
19 |
39 |
19 |
31 |
Jessica |
Senior Analyst |
20 |
34 |
30 |
35 |
34 |
30 |
29 |
24 |
Julia |
Business Analyst |
15 |
34 |
28 |
22 |
27 |
36 |
38 |
19 |
Resource Name |
Resource Level |
July |
August |
September |
Rob |
Manager |
|
|
|
Tom |
Analyst |
|
|
|
Jessica |
Senior Analyst |
|
|
|
Julia |
Business Analyst |
|
|
|
Best Answer
Instead of using
XLOOKUP()
use eitherSUM()
orSUMPRODUCT()
. The following is the simplest of all and remember aSUM()
function will be always efficient and quicker, there is no match to it.When you have output data laid out where you have the resource name and resource level on the left, and the headers with the formatting as
mmm-e
you can simply use theSUM()
function performing a Boolean Logical Operation, no fancy formulas or functions are required. It is way easy to understand and easy to debug, moreover it will be very efficient as well. Just try !Otherwise if you are attempting for second dynamic array formula then use the Option Two which I have proposed.
OPTION TWO:
Instead of using multiple
LAMBDA()
iterations using functions likeREDUCE()
orCustom LAMBDA()
with a combination of anotherLAMBDA()
helper likeMAP()
you can easily transform your data into one single dynamic array usingMMULT()
:Please ensure to convert your range into
Structured References
akaTables
. There are many reasons to use this feature of excel. Two such reasons are it makes easier to read the formulas as well as it will auto resize the formula when there is a change in dimensions of the source data.To explain more clearly please read:
_Data
Variable refers to the entire tableTable1[#All]
Rname
Variable extracts the first columns from the source excluding the headers usingTAKE()
andDROP()
-->TAKE()
helps in taking the first column whileDROP()
involves in dropping the headers._Rlevel
Variable Similarly extracts the second column from the source likewise above using the same methodology by changing thecolumn_index
in theINDEX()
_Headers
Variable extracts the first row usingTAKE()
function whileDROP()
helps in removing first two columns, and lastly usingTEXT()
function which formats the dates as a three-letter abbreviation of the month followed by a dash/hyphen and the year.The formatting notation for the full name of the month ismmmm
while for onlyJul
orApr
etc it would be likemmm
which already been used,e
refers to the year which is universal._Uniq
Variable refers to unique list of headers._Body
Variable is the values areas, extracted usingDROP()
function._Rname
andRlevel
with the matrix multiplication of_Body
and aBinary array created between the
_Uniqlist and the transposed
_Headers, enclosed within
HSTACK()` to return one single output.VSTACK()
to give some better look we are placing the headers!.