# Help with GROUP BY Query?

**URL:** https://community.tiller.com/t/help-with-group-by-query/29970
**Category:** Google Sheets
**Created:** [January 9, 2025, 9:47pm UTC](https://community.tiller.com/t/help-with-group-by-query/29970 "2025-01-09T21:47:50Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![eliande](https://sea2.discourse-cdn.com/flex020/user_avatar/community.tiller.com/eliande/32/189_2.png) [@eliande](https://community.tiller.com/u/eliande)
#### Post date: [January 9, 2025, 9:47pm UTC](https://community.tiller.com/t/help-with-group-by-query/29970/1 "2025-01-09T21:47:50Z")

</div>

Hi there!

Apologies for a very newbie question, but I am just starting to explore the wonderful world of Google Query in my Tiller spreadsheet. I was attempting to use GROUP BY to sum the total value of transactions by Month, but I keep getting a #Value! error and I have no idea what I’m doing wrong. Can anyone help?

Here’s the formula I’m using:  
=query(Transactions!A1:U9172, “SELECT Col2, Col3, Col4, Col5, Col6, Col12, sum(Col7) WHERE Col7 is not null GROUP BY Col12”,-1)

where

- Transactions!A1:U9172 = my transactions database (will need to make this reference dynamic later)
- Col2 = Date
- Col3 = Description
- Col4 = Category
- Col5 = Group
- Col6 = Tags
- Col12 = Month
- Col7 = Amount

I’ve been through an bunch of online YouTube videos at this point and can’t figure out what I’m doing wrong. I can filter using WHERE for Col12 = date ‘2025-01-01’ but if I try to SUM(Col7) I get the #Value! error. What am I doing wrong with SUM? Any help would be deeply deeply appreciated!

Thanks,  
Diana

---

<div class="post-metadata">

### Author: ![Mark.S](https://sea2.discourse-cdn.com/flex020/user_avatar/community.tiller.com/mark.s/32/14650_2.png) [@Mark.S](https://community.tiller.com/u/Mark.S)
#### Post date: [January 10, 2025, 1:54am UTC](https://community.tiller.com/t/help-with-group-by-query/29970/2 "2025-01-10T01:54:05Z")

</div>

QUERY is indeed a powerful function 🙂

Try changing your `SELECT` to:  
`SELECT Col12, sum(Col7)`

Once you aggregate and group by Month, the other non-aggregated columns cannot be displayed.

I believe your `QUERY` result will be a monthly cashflow type value, assuming transfers within the month all cancel to zero. If you want monthly expenses, then consider adding a `Category Type` to your Transactions sheet to filter by.

---

<div class="post-metadata">

### Author: ![eliande](https://sea2.discourse-cdn.com/flex020/user_avatar/community.tiller.com/eliande/32/189_2.png) [@eliande](https://community.tiller.com/u/eliande)
#### Post date: [January 10, 2025, 1:26pm UTC](https://community.tiller.com/t/help-with-group-by-query/29970/3 "2025-01-10T13:26:45Z")

</div>

Hi Mark! Thanks so much for your help! The extra Col in SELECT were exactly the problem!! : ) It’s working now!! Yay!!!

---

<div class="post-metadata">

### Author: ![Mark.S](https://sea2.discourse-cdn.com/flex020/user_avatar/community.tiller.com/mark.s/32/14650_2.png) [@Mark.S](https://community.tiller.com/u/Mark.S)
#### Post date: [January 10, 2025, 3:05pm UTC](https://community.tiller.com/t/help-with-group-by-query/29970/4 "2025-01-10T15:05:14Z")

</div>

Good to hear and happy exploring 🙂

You might also consider something like `GROUP BY` Category `PIVOT` Month 🤔

---

<div class="post-metadata">

### Author: ![eliande](https://sea2.discourse-cdn.com/flex020/user_avatar/community.tiller.com/eliande/32/189_2.png) [@eliande](https://community.tiller.com/u/eliande)
#### Post date: [January 10, 2025, 10:37pm UTC](https://community.tiller.com/t/help-with-group-by-query/29970/5 "2025-01-10T22:37:20Z")

</div>

Look what I made! : ) (It’s total spend by category per month across the last 3 years.) I’m a bit limited by the inability of Google Sheets to make very complex graphs but I’m pretty proud of myself. Thank you so much for your help with the Query function!

 ![image](https://us1.discourse-cdn.com/flex020/uploads/tillermoney/original/3X/8/b/8b4c364013ef0b00a750638d7c578cf4dae320d3.png)

---

<div class="post-metadata">

### Author: ![Mark.S](https://sea2.discourse-cdn.com/flex020/user_avatar/community.tiller.com/mark.s/32/14650_2.png) [@Mark.S](https://community.tiller.com/u/Mark.S)
#### Post date: [January 10, 2025, 10:55pm UTC](https://community.tiller.com/t/help-with-group-by-query/29970/6 "2025-01-10T22:55:21Z")

</div>

Pretty chart - you’re quickly becoming a pro 👍
