Sum values between dates in Excel practice workbook

Get the Sum Between Dates Workbook

The workbook from the video, with a practice sheet and the finished solution. Sum revenue between two dates, by month, and by month and app.

This tutorial explores how to SUM values using dates in creative situations:

  • SUM values between two dates
  • SUM values by month
  • SUM values based on multiple criteria

The below data set has a list of sales by DATE sold, APP sold, and REVENUE.

Excel sales data with Date, App and Revenue columns used to sum values between dates

How to Sum Values Between Two Dates

We have a list of dates and we wish to sum all of the Revenue between each date pair.

Table of From and To date pairs with an empty Revenue column to fill with SUMIFS

The function we will use is SUMIFS.  The structure of SUMIFS is…

=SUMIFS(sum_range, criteria_range1, criteria1, …)

SUMIFS accepts up to 127 range and criteria pairs. It adds up only the rows that meet every condition.

NOTE: All of the defined criteria are examined with a logical AND; meaning, all of the criteria must match for the sum range to qualify for inclusion in the final sum operation.

Example: If the Color is “Red” and the Size is “Large” then Sum the Sales.  There could be other “Large” items but they may not be “Red”, and vice-versa.  Both criteria must be met to qualify.

In our sample file, we want to sum the Revenue if the sale date falls between the “From” date and the “To” date.

Select cell J6 and enter the following formula:

=SUMIFS($C$4:$C$33, $A$4:$A$33, ">="&H6, $A$4:$A$33, "<="&I6)
SUMIFS result of 205,740 revenue between 6/1/2018 and 7/15/2018

Use the Fill handle to drag the formula down to cell J8.

SUMIFS formula filled down to sum revenue for all three date ranges

Include or Exclude the Start and End Dates

Watch out for shared dates. In the example, the first period ends on 7/15/2018 and the second one starts on the same day. With >= and <= on both, a sale on July 15 is counted twice.

When periods share a boundary, use > for the start date. That’s what the finished sheet in the workbook does.

How to Sum Values by Month

Create a List of Months

The first step is to generate a list of months.  Although we want the user to see the months as Jun-18, Jul-18, Aug-18, etc…, we will start by entering in the months as actual dates.

Select cell H14 and enter the first day of the month. In the US date format that’s:

6/1/2018

Using the Fill handle, drag down to cell H17.

Because we don’t want a sequence of days, we want a sequence of months, click the Auto Fill Options button and select Fill Months.

Auto Fill Options menu with Fill Months selected to create a list of month start dates

Now that we have our months, we will format the months by pressing CTRL-1 (or right-click Format Cells.)  From the Category list, select Date and then select the “Mar-12” format and click OK.

Format Cells dialog with the Date category and the Mar-12 format selected to show months as Jun-18

The result should appear as follows.

List of months formatted as Jun-18 to Sep-18 ready for the monthly SUMIFS totals

To calculate the Revenue, we are presented with a bit of a problem.  We have the start date of each month (H14:H17), but what we lack is the end dates for those months.

Find the Last Day of the Month with EOMONTH

To solve this problem, we will use an often overlooked yet quite useful function called EOMONTH.  The structure of EOMONTH is…

=EOMONTH(start_date, months)

The EOMONTH function accepts a date as its first argument and then a number as its second argument. The number defines how many months (forward or backward in time) you want to travel.  Not only does it “travel” to the requested month, but it selects the last day of the resultant month.

Example:

EOMONTH examples returning the last day of the month 4 months ahead, 4 months back and in the same month

By using 0 (zero) as the number of months to travel, we will remain in the current month but move to the last day of that month.

Sum Each Month with SUMIFS

Now create the formula using SUMIFS and the EOMONTH functions.  In cell J14 enter the following formula:

=SUMIFS($C$4:$C$33, $A$4:$A$33, ">="&H14, $A$4:$A$33, "<="&EOMONTH(H14, 0))

The result for June is as follows.

SUMIFS with EOMONTH returning the June revenue total of 68,592

Use the Fill handle to fill the formula from cells J14 through J17.

Monthly revenue totals for June to September calculated with SUMIFS and EOMONTH

How to Sum by Month with Multiple Criteria

The final problem is to perform the same calculation as in Problem #2, but include an extra step where we only calculate for a month of revenue for a given App (ex: Revenue for Utility in June).

The formula is identical to the formula created to solve Problem #2, so copy it and add one more condition for the App.

Copy/paste the formula from cell J14 into cell J23. Then add the App condition at the end:

=SUMIFS($C$4:$C$33, $A$4:$A$33, ">="&H23, $A$4:$A$33, "<="&EOMONTH(H23, 0), $B$4:$B$33, I23)

Since I23 contains an App name, the SUM will be restricted to not only the requested month but also the requested App.

Need the matching rows themselves, not just the total? Use FILTER with multiple criteria to list every sale in the date range.

Monthly revenue by app table with the first result of 44,196 for Utility in June

Use the Fill handle to fill the formula from cells J23 through J34.

SUMIFS results for every month and app combination from June to September

Download the Sum Between Dates Workbook

Download the Sum Between Dates Workbook

Practice all three SUMIFS date formulas, then check your answers on the finished sheet.

Frequently Asked Questions

How do I sum values between two dates in Excel?

Use SUMIFS with the date column twice. The first condition keeps dates on or after the start date, the second keeps dates on or before the end date. Put the start and end dates in cells and join them to the operators with an ampersand.

Does SUMIFS include the start and end dates?

Only if you use greater than or equal to and less than or equal to. With plain greater than or less than, the start and end dates are left out. If two periods share a boundary date, exclude it from one of them so nothing is counted twice.

How do I sum values by month in Excel?

List the first day of each month in a column. Then use SUMIFS with that date as the start and EOMONTH of the same date with 0 months as the end. Fill the formula down to get a total for every month.

What does the EOMONTH function do?

EOMONTH returns the last day of a month. The first argument is a date, the second is the number of months to move forward or back. With 0 you get the last day of the same month, with 1 the last day of the next month.

How do I sum between two dates with another condition?

Add another range and criteria pair to the same SUMIFS formula, such as the product column and the product name. SUMIFS only adds a row when every condition is true, and it accepts up to 127 pairs.

Why does my SUMIFS date formula return 0?

The most common cause is dates stored as text, which SUMIFS cannot compare. Check that the dates are right-aligned or change the format to General to see a number. Also check that the operator sits inside quotes and the date cell is joined with an ampersand.

Leila Gharani

Founder of XelPlus and ten-time Microsoft MVP. Leila helps over 500,000 professionals master Excel, Power BI, and data automation through practical, real-world training.