# How to Sum by Week in Google Sheets (With Example)

Often you may want to sum the values of some dataset in Google Sheets based on week.

The following step-by-step example shows how to do so.

## Step 1: Enter the Data

First, enter the values for a dataset that show the total sales of some product on various dates:

## Step 2: Extract the Week from Dates

Next, we will use the WEEKNUM function to extract the week from each date.

In our example, we’ll type the following formula in cell D2:

```=WEEKNUM(A2)
```

We’ll then drag and fill this formula down to every remaining cell in column D:

## Step 3: Find the Unique Weeks

Next, we need to use the UNIQUE function to produce a list of unique weeks.

In our example, we’ll type the following formula in cell E2:

```=UNIQUE(D2:D12)
```

This will produce a list of unique weeks:

## Step 4: Calculate the Sum by Week

Next, we will use the SUMIF(range, criterion, sum_range) function to find the sum of the sales made during each week.

In our example, we’ll type the following formula in cell F2:

```=SUMIF(\$D\$2:\$D\$12, E2, \$B\$2:\$B\$12)
```

We’ll then drag and fill this formula down to the remaining cells in column F:

From the output we can see

• There were 22 total sales made in the first week of the year.
• There were 24 total sales made in the second week of the year.
• There were 63 total sales made in the third week of the year.

And so on.