Friday, August 9, 2013

Google Spreadsheet Group By Query Sum

Question:

( by rmeghdie )



Hello,

Here's what my data looks like:
Group  -  Number
y                5
y                2
d                5
y                2
d                2
y                9
b                2
y                9


In a cell bellow I want to say if the "Group" is y then add the "Number" to the total in this cell.

So in this case the total would be: 5+2+2+9+9 = 27

Is this possible?

Solution:

Have a look at the following screenshot:



I have the following formula in Cell E2:
=sumif(A:A;E1;B:B)

the above formula will give you the result for "y" as we have "y" in Cell E1.
And if you change the value of Cel E1 to "d", then it will give you the result as 7 in Cell E2.


And you can also have a group by query, I have the following formula in Cell G1:
=query(A:B;"select A,sum(B) where A <>'' group by A label sum(B) 'Total' ";1)

the above formula will auto generate the table by summing all the unique values of Column A.


I hope the above solution will help you, and if you need more help then please do comment below on this blog itself, I will try to help you out.


I also take up private and confidential projects:
If this blog post was helpful to you, and if you think you want to help me too and make my this blog survive then please donate here: http://igoogledrive.blogspot.com/2012/09/donate.html 

Thanks,

No comments:

Post a Comment