Sum by Week Number in Excel (Dynamic Array Formula Included)

To sum by week number, we’ll utilize the WEEKNUM, UNIQUE, and SUMIF functions in Excel using the traditional approach.

If you prefer a dynamic array formula to accomplish this task, then SUMIF won’t suffice. Instead, we’ll replace it with SUMPRODUCT and utilize the MAP lambda function to generate an array result. The dynamic array formula avoids helper columns and creates a week number summary that spills down.

We’ll examine both options.

Setting Up the Sample Data

We need at least two columns of data: one containing dates and the other containing values to sum.

Consider the following data in cell range A1:B10 in an Excel spreadsheet:

DATEVALUE
01-04-20245
05-04-20244
10-04-20245
12-04-20246
13-04-20245
22-04-20245
25-04-20244
26-04-20245
27-04-20244

Follow the steps below to sum by week numbers in Excel.

Sum by Week in Excel: Traditional SUMIF and WEEKNUM Approach

The formula is a SUMIF, but we will use the WEEKNUM and UNIQUE functions to extract week numbers and make them unique.

Syntax: SUMIF(range, criteria, [sum_range])

range:

We need to extract the week numbers from the dates in A2:A10. Enter the following formula in cell D2:

=WEEKNUM(A2)

Click and drag the bottom right fill handle (which turns into a plus sign) in cell D2 down to cell D10.

Generating Week Numbers (Drag-Down Formula)

criteria:

In cell E2, enter the following UNIQUE formula to return an array containing unique week numbers:

=UNIQUE(D2:D10)
Excel formula to return the unique week numbers

sum_range:

The sum_range, which we will specify inside the SUMIF formula, is B2:B10.

Sum by Week Number Formula:

In cell F2, enter the following formula and drag the fill handle until F4:

=SUMIF($D$2:$D$10, E2, $B$2:$B$10)

$D$2:$D$10 represents the range, E2 is the criteria, and $B$2:$B$10 is the sum_range.

SUMIF drag-down formula to sum by week in Excel (Traditional Approach)

Note: The formula considers Sunday to Saturday weeks for week number extraction. If your week starts on Monday and ends on Sunday, use =WEEKNUM(A2, 2) instead of =WEEKNUM(A2).

Sum by Week Using a Dynamic Array Formula in Excel

Disclaimer:

I tested the following formula in Excel in Microsoft 365. It will not function in Excel versions that lack dynamic array formula functionality.

Dynamic Array Formula for Sum by Week in Excel

Formula:

=LET(
   range, A2:A10, 
   sum_range, B2:B10, 
   criteria, UNIQUE(MAP(range,LAMBDA(val,WEEKNUM(val)))), 
   HSTACK(
      criteria, 
      MAP(criteria, LAMBDA(val, 
         SUMPRODUCT(
            (MAP(range, LAMBDA(val, WEEKNUM(val)))=val)*sum_range
         )
      ))
   )
)

How do I use this formula?

Input this formula into cell D2. It will return the sum by week without needing to be dragged down.

When using this Excel dynamic array formula with your table, replace A2:A10 with the date range (range) and B2:B10 with the sum range.

This formula takes care of everything on its own!

How Can I Specify a Different Week Start and End?

In the dynamic array formula for sum by week, you can see the use of WEEKNUM(val) twice. It uses week number type 1, which corresponds to Sunday to Saturday.

To specify Monday to Sunday, replace them with WEEKNUM(val, 2). The “2” in this WEEKNUM function is called return_type in Excel.

For the return_types, please refer to this table:

Weekreturn_type
Sun-Sat1 or omitted
Mon-Sun2
Mon-Sun11
Tue-Mon12
Wed-Tue13
Thu-Wed14
Fri-Thu15
Sat-Fri16
Sun-Sat17
Mon – Sun21

In return_types 1, 2, and 11 to 17, the week containing January 1st is considered as week 1. In return_type 21, the week containing the 1st Thursday of the year is numbered as week 1.

Resources

  1. Creating a Running Balance with Dynamic Array Formulas in Excel
  2. Running Count of Occurrences in Excel (Includes Dynamic Array)
Prashanth KV
Prashanth KV
Your Trusted Google Sheets and Excel Expert Prashanth KV is a Diamond Product Expert in Google Sheets, officially recognized by Google for his contributions to the Docs Editors Help Community and featured in the Google Product Experts Directory. Explore his blog to learn advanced formulas, automation tips, and problem-solving techniques to elevate your spreadsheet skills.

Mode of Comma-Separated Numbers in Excel (Dynamic Array)

There is no dedicated function in Excel to directly find the mode of comma-separated...

How to Find Mode of Comma-Separated Numbers in Google Sheets

Working with comma-separated numbers inside a single cell is a common scenario in Google...

How to Count Merged Cells in Google Sheets (and Get Their Size)

Sometimes, you may have blocks of merged cells in a column or row. But...

Count Consecutive Workday Absences in Google Sheets

This tutorial offers a powerful formula-based solution to count consecutive workday absences in Google...

More like this

Mode of Comma-Separated Numbers in Excel (Dynamic Array)

There is no dedicated function in Excel to directly find the mode of comma-separated...

Sort Each Row Individually in Excel Using a LAMBDA Formula

Sorting rows in Excel typically refers to rearranging entire datasets based on values in...

Sort by Field Labels Using the SORT and XMATCH Combo in Excel

Want to sort your Excel data by column names instead of column positions? Learn...

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.