# Average Amounts for Each Day of the Week in Google Sheets

This Google Sheets tutorial details two methods to average transaction values by each day of the week. We’ll explore the versatility of the QUERY function and delve into the power of Pivot Tables to find the averages. Let’s get started!

## Desired Outcome

First, let’s define our goal. We want to find averages for each day of the week from a list of transactions on multiple days. The output will be a list of each day next to its corresponding average.

Let’s start with the first solution. If you’re not a fan of long formulas, this is the one for you.

## Example 1 – Pivot Table with Date Grouping

This first example will use the built-in date grouping feature for pivot tables in Google Sheets. This feature will do most of the work for you, eliminating the need for formulas.

Pivot tables summarize large amounts of data using menus instead of formulas. See this YouTube video for a primer on pivot tables if you are unfamiliar with them.

Start by going to the Insert menu, then choosing pivot table. Specify `A1:C1001` as the data range.

Press OK once you have the correct data range.

⚠️ Native pivot tables can have only one data range. Use OmniPivot if you have more than one range.

After selecting the data range, Google Sheets will ask where you want the Pivot table.

We’ll place it on the Existing sheet in cell E2. Choose the location and click Create.

Clicking the Create button opens the Pivot table editor in the sidebar. In the editor, we’ll drag and drop the Manufacture Date field into the Rows and the Price field into the Values.

Now, change the Summarize by option in the Values section from `SUM` to `AVERAGE`.

Then, right-click on the dates, choose Create pivot date group, and select Day of the week.

Now, you have a finished pivot table with the amounts averaged by each day of the week.

As you can see, pivot tables do much of the work without code. However, the query function is the best fit if you want to use a formula. Let’s look at that now.

## Example 2 – Query Function

The query function is in a class of its own compared to traditional spreadsheet functions. It allows the spreadsheet user to write SQL commands inside the formula. We’ll use query to average the amounts by day, just as we did above, but with one formula. Let’s take a look at the query syntax.

### Query Function Syntax

`=QUERY(data, query, [headers])`

• `data` – Location of the data
• `query` – The query statement. The query is composed of optional clauses that you must use in order.
• `select` – The columns to return. If omitted, the query returns all columns.
• `where` – Conditions that rows must meet
• group by – Aggregates values
• `pivot` – Aggregates values into new columns
• `order by` – Sorts rows by values
• `limit` – Limits the number of rows returned
• `offset` – Skips a specified number of rows
• `label` – Creates column labels
• `format` – Formats outputs
• `options` – Sets additional options
• `[headers]` – The number of header rows at the top of the `data`

### Writing the Query

Now that we know the syntax let’s write out the formula. We will still use `A1:C1001` as the `range`, and there’s one `header` row. So, we know the values for the `data` and `headers` arguments. Here is what we have so far:

`=QUERY(A2:C1001, query, 1)`

For the query, we want to return a column for the day of the week and a column for the averages. SQL has a scalar function called `dayOfWeek` and an aggregation function called `average`. We’ll use both of those. We’ll then use the `group by` clause to tell the function how to show the output, and we’ll add headers using the `label` clause. To polish it off, we’ll use the `format` clause to change the day numbers to words and the numbers to currency. This is what the formula looks like now:

`=QUERY(A1:C1001, "select dayOfWeek(Col2), average(Col3) group by dayOfWeek(Col2) label dayOfWeek(Col2)'Day',average(Col3)'Average' format dayOfWeek(Col2)'dddd',average(Col3)'\$#,##0'", 1)`

The long formula creates this simple, compact table of just the data you need, sorted by day of the week!

## Conclusion

Google Sheets has two great options for averaging data by each day of the week. Choose the pivot table for ease of use and the query function for the flexibility of a formula written in SQL. Whichever technique you use, you’ll get the answer you’re looking for.

## Related Tutorials

• ###### Average Amounts for Each Day of the Week in Google Sheets

Learn two methods to average amounts by day of the week.

• ###### Sum Amounts for Each Day of the Week in Google Sheets

Learn two techniques to sum values by day of the week.

• ###### Types of Date and Time Functions in Google Sheets

The date and time functions in Google Sheets can be grouped into different categories based on their purpose.