Same Day Last Week Comparison in Google Sheets

Do you know how to compare the sales during this week with the sales during the same days last week in Google Sheets? If not, in this tutorial – Same Days Last Week Comparison in Google Sheets – I am going to explain the same.

Please note that I am not talking about the comparison of the total/cumulative sales of this week with the total/cumulative sales of the last week.

I want to compare the sales of this Monday with the sales of last Monday, this Tuesday with the last Tuesday and so on.

Same day last week comparison is possible in Google Sheets with a few formulas.

If there are two or more sales on the same day we will summarize that before comparing. So you won’t face any issue regarding multiple data entry (sales) on the same day.

In some cases, there won’t be multiple data. For example, website traffic today vs website traffic the same day last week.

There won’t be multiple data because you might be only tracking data from Google Analytics, not from multiple sources like Facebook, Pinterest, etc.

What I am trying to say is, my same day last week comparison formula in Google Sheets will work irrespective of the number of records on any day.

Let’s learn more about the same day this week vs same day last week comparison in Google Sheets below.

This Week vs Same Days Last Week Comparison in Google Sheets (Step by Step Instructions)

Sample Data: To save your time, copy the data (or use the copy of the sheet itself) by following the below link.

Sample Sheet_Formulas

Same Day This Week vs Last Week Comparison in Google Sheets

I hope you have copied the sheet. Let’s begin.

Filter This Week’s and Last Week’s Records (Data)

There is one important aspect to consider in our so-called same day last week comparison in Google Sheets. What’s that?

We can consider this week and last week based on week numbers or this 7 days vs last 7 days approach.

Didn’t get?

Based on Current and Previous Week Numbers

Assume today is Thu, 26 Mar 2020. Then the dates that fall in this week will be the dates from Sun, 22 Mar 2020 to Thu, 26 Mar 2020.

What about last week’s data?

No doubt, it will be from Sun, 15 Mar 2020 to Sat, 21 Mar 2020.

In my tutorial titled, Filter Data Based on This Week, Last Week, Last 30 Days in Google Sheets, I have explained the use of month numbers to filter this week’s as well as last week’s data.

Note: No need to insert the following 4 Filter formulas in your sheet. But you can insert it to see the results. We want these formulas (not all) later.

This Week (Formula # 1)

=filter(A2:B,Weeknum(A2:A)=weeknum(today()))

Last Week (Formula # 2)

=filter(A2:B,Weeknum(A2:A)=weeknum(today()-WEEKDAY(today())))

I will later use the below two filters (not the above ones) for my same day last week comparison formula in Google Sheets.

Based on This 7 Days vs Last 7 Days

As per this approach, if today’s date is Thu, 26 Mar 2020, this week will be from Fri, 20 Mar 2020 to Thu, 26 Mar 2020. Last week will be from Fri, 13 Mar 2020 to Thu, 19 Mar 2020.

This Week (Formula # 3):

=filter($A$2:$B,$A$2:$A>today()-7,$A$2:$A<=today())

Last Week (Formula # 4):

=filter($A$2:$B,$A$2:$A>today()-14,A2:A<=today()-7)

There are two formulas each for this week’s and last week’s filter. Choose which one you want. I’ll use option # 2, i.e. the formulas 3 and 4.

You can try both the options to see the changes in the output. I’ll tell you where you can use the above formulas.

Summarizing the Sales – This Week and Last Week

Now the next step in our same day this week vs same day last week comparison is summarizing the filtered data.

We can use the above formulas in Query as the ‘data’.

Syntax: QUERY(data, query, [headers])

We can use the Group By clause in Query to summarize the data. Read my guide – What is the Correct Clause Order in Google Sheets Query? – to get familiar with the said clause (grouping) and other clauses in Query.

This Week’s Sales Summary Formula in Cell D1: Here in this, the Query ‘data’ argument is the formula # 3 above.

=query(filter($A$2:$B,$A$2:$A>today()-7,$A$2:$A<=today()),"Select Col1, Sum(Col2) where Col1 is not null group by Col1 label Sum(Col2)'This Week', Col1'Date'",0)
Query to Filter and Summarize This Week's Records

Last Week’s Summary in Cell F1: Here in this, the Query ‘data’ argument is the formula # 4 above.

=query(filter($A$2:$B,$A$2:$A>today()-14,A2:A<=today()-7),"Select Col1, Sum(Col2) where Col1 is not null group by Col1")

We need one modification to the cell F1 formula. I’ll explain that below.

Vlookup for the Same Day Last Week Comparison in Google Sheets

We have this week’s dates in the array D2:D8 and last week’s date in the array F2:F8, right?

Vlookup for the Same Day Last Week Comparison in Google Sheets

The array formula =ArrayFormula(D2:D-7) can populate the same dates that you can find in F2:F8. We will use this formula in Vlookup.

In cell F1, we can use a Vlookup formula by modifying the existing formula in that cell. In that Vlookup, the ‘search_keys’ will be the above array formula (see the paragraph above) and the ‘range’ argument will be the existing F1 formula.

Syntax: VLOOKUP(search_key, range, index, [is_sorted])

Generic Formula:

=ArrayFormula(vlookup(ArrayFormula(D2:D-7),F1_formula,2,0))

So it will be;

=ArrayFormula(vlookup(ArrayFormula(D2:D-7),query(filter($A$2:$B,$A$2:$A>today()-14,A2:A<=today()-7),"Select Col1, Sum(Col2) where Col1 is not null group by Col1"),2,0))

After adding the title (after further modification);

=ArrayFormula({"Last Week";ifna(Vlookup($D$2:$D-7,query(filter($A$2:$B,$A$2:$A>today()-14,A2:A<=today()-7),"Select Col1, Sum(Col2) where Col1 is not null group by Col1"),2,0))})

Percentage of Increase or Decrease in Comparison to Same Day Last Week

We have just completed our same day last week data comparison in Google Sheets. But I think the comparison won’t be complete without a column of data with the percentage of increase or decrease.

Assume the total sales on Fri, 20 Mar 2020 is 1323.00 and the same day last week, i.e. on Fri, 13 Mar 2020, is 283.00.

You can calculate the percentage of increase or decrease of the same day this week vs same data last week value as below.

=(1323-283)/283

The above is equal to 3.6749, which would be 367.49% if formatted to percentage. That means 1323 is a 367.49% increase of 283.

We can calculate the same using an array formula in cell G1 as below.

=ArrayFormula({"% of Decrease";if(D2:D="",,TO_PERCENT((E2:E-F2:F)/F2:F))})

Note: See the below calculation.

=(1323-283)/1323

It will return 78.61% that means 283 is a 78.61% decrease of 1323. If you want this in column G, use the below formula in G1.

=ArrayFormula({"% of Decrease";if(D2:D="",,TO_PERCENT((E2:E-F2:F)/E2:E))})

That’s all about the same day last week comparison in Google Sheets.

Resources

Prashanth KV
Prashanth KV
Your Trusted Google Sheets and Excel Guide Prashanth KV brings a wealth of experience in Google Sheets and Excel, cultivated through years of work with multinational corporations in Mumbai and Dubai. As a recognized Google Product Expert in Docs Editors, Prashanth shares his expertise through insightful blogging since 2012. Explore his blog for practical tips and guidance on maximizing your spreadsheet skills.

Hierarchical Numbering Sequences in Excel

Creating hierarchical numbering sequences in an Excel spreadsheet can significantly improve the way you...

How to Easily Repeat a Sequence of Numbers in Excel

Excel offers multiple ways to accomplish tasks, and the simplicity of each approach depends...

Create a Sequence of Dates at Every Nth Row in Excel (Dynamic Array)

Would you like to create a sequence of dates in every nth row in...

XMATCH Row by Row: Finding Values Across a Range in Google Sheets

Using the BYROW function with XMATCH in Google Sheets allows us to match values...

More like this

XMATCH Row by Row: Finding Values Across a Range in Google Sheets

Using the BYROW function with XMATCH in Google Sheets allows us to match values...

Limit Formula Expansion to a Specific Row in Google Sheets

In this tutorial, I’ll explain how to limit the expansion of an array formula...

3-D Referencing Structured Data Tables in Google Sheets

When you have several tables within a single sheet—not across multiple sheets in a...

4 COMMENTS

  1. Hi Prashanth,

    Here’s a copy (removed by admin) where I have managed to use a query to display a pivot by month and year. Not sure how to make this work and display by day or week? So basically I’d like to show every day of the year if possible. If not then at least each week of the year if that is easier.

    • I have seen your Pivot report. The first column in the report is not month numbers. It’s “day of the year” grouping. So it’s not month and year as you have mentioned.

  2. Hi Prashanth,

    I’m a fan of all your google sheets tips.

    I had a search of your archive and trying a few things myself, but one thing that is defeating me is finding a solution to this problem.

    I want to list each day of the year by row and then in the columns, I’d like to show a sequence of years.

    I’d then like to extract the sum of sales for each day of each year (my raw data shows the value of each sale and the date confirmed) so they are shown side-by-side allowing me to put together a chart or further analysis. Any tips much appreciated.

    Andy

    • Hi, Andy H,

      I think I can help you. You may require to use a Query formula. To help, I may require a mockup sheet. Consider sharing it (link/URL) in the comments below (I won’t publish it).

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.