# Using SUM, ARRAYFORMULA and VLOOKUP in Google Sheets

I'm trying to SUM the hours of employees. The list is sorted by WE date and name.

The employees name is in U3. I tried multiple variations of:

``````=ARRAYFORMULA(SUM(VLOOKUP(U3,Data_for_2022!B2:K2000,{8,9,10},FALSE)))
=SUMIF(Data_for_2022!B2:B2000,"=U3",Data_for_2022!I2:K2000)
``````

The arrayformula only returns the sum of values from the first line SUMIF returns 0

Here is what the data look like:

• VLOOKUP only returns one entry per match. As for your SUMIF, it's written incorrectly. For starters, `"=U3"` would need to be simply `U3`. At a glance, however, there are other issues as well. An image is not terribly helpful, since it doesn't provide readily accessible date for the volunteer contributors here to work with (unless you expected people to start their own spreadsheet and manually enter your data themselves, which I'm sure you don't). Consider sharing a link to the spreadsheet or to a safe copy of it. Mar 29, 2022 at 21:02
• Got it. Thanks. Apr 1, 2022 at 21:28

## 1 Answer

Use `query()` to get a list of all names and aggregate the hours, like this:

`=query(Data_for_2022!B1:K, "select B, sum(K) where B is not null group by B", 1)`

• I feel really dumb. I didn't even think of using a query. You rock. Thank you!! Mar 31, 2022 at 1:22