How to Sum Multiple Columns using Query function
To sum multiple columns using the Query function in Google Sheets, follow these steps:
- Open your Google Sheet.
- Identify the range of cells that you want to sum. For example, if you want to sum columns B, C, and D for rows 2 to 10, your range will be B2:D10.
- Click on an empty cell where you want to display the summed values.
- Enter the Query function in the following format:
=QUERY(range, "SELECT SUM(Col1), SUM(Col2), SUM(Col3) GROUP BY Col1 LABEL SUM(Col1) 'Sum of Col B', SUM(Col2) 'Sum of Col C', SUM(Col3) 'Sum of Col D'")
Replacerange
with your actual cell range, and replaceCol1
,Col2
, andCol3
with the respective column numbers you want to sum.
Example
Let's say we have the following data in Google Sheets:
A B C D
1 Name Sales Profit Expenses
2 John 100 50 20
3 Jane 200 60 30
4 Joe 300 70 40
To sum columns B, C, and D, follow these steps:
- Click on an empty cell, let's say E1.
- Enter the following Query function:
=QUERY(B2:D4, "SELECT SUM(Col1), SUM(Col2), SUM(Col3) GROUP BY Col1 LABEL SUM(Col1) 'Sum of Sales', SUM(Col2) 'Sum of Profit', SUM(Col3) 'Sum of Expenses'")
The final result will look like this:
A B C D E
1 Name Sales Profit Expenses Sum of Sales Sum of Profit Sum of Expenses
2 John 100 50 20 600 180 90
3 Jane 200 60 30
4 Joe 300 70 40
In this example, the Query function calculates the sum of Sales (600), the sum of Profit (180), and the sum of Expenses (90) and displays them in columns E, F, and G, respectively.
Did you find this useful?