Home > Back-end >  sum the numbers in the second Column according to data in the first column
sum the numbers in the second Column according to data in the first column

Time:03-01

      A                       B                       C

1 Timestamp Hours Worked Total Hours 2 1/2/2022 17:33:41 6 3 1/3/2022 19:59:41 2 January = 4 1/7/2022 13:20:51 1 5 1/9/2022 12:49:02 3 February = 6 1/15/2022 12:04:21 3 7 2/16/2022 15:58:10 9 March = 8 2/22/2022 11:57:31 3 9 2/24/2022 5:45:12 5 10 2/2/2022 17:33:41 4 11 2/3/2022 19:59:41 2 12 2/7/2022 13:20:51 1 13 3/9/2022 12:49:02 3 14 3/15/2022 12:04:28 3 15 3/16/2022 15:58:10 7 16 3/22/2022 11:57:31 3 17 3/24/2022 5:45:12 5

I would like to sum the hours by date/month. I can sum the hours by column, =sum(b2:b). But how do I sum the hours in Column B by date/month of column A?

In another post, a member referenced the 'Google Sheets function list'. I have found that to be very helpful on other things I have been doing. But I am still at a lose for this problem.

John

CodePudding user response:

The simplest solution, without any formula, is to build a pivot table.

CodePudding user response:

You could use the query function with SQL:

=QUERY({(data)}, "select sum(Col2) group by Col1 label Col1 'Date', Col2 'Sum'")

That would return a new table, and you can adjust it by changing the second parameter, representing the SQL string. You can view Google's docs for the query function here. In addition you can find their docs for the query language here.

  • Related