Using a Week Number as One Criterion in a Formula

Dave is trying to create a SUMIFS formula that uses the year as one criterion and the week number as another criterion. This will allow him, for instance, to sum all the values from a particular week in a previous year. The week number criteria needs to be based on whatever week number the current date is within. Thus, if today is within week 3, the formula needs to include weeks 1, 2, and 3 from whatever year he specifies. Dave is sure there is a way to do this, but he can’t figure out the right way to express it in SUMIFS.

Using the SUMIFS worksheet function, it is important to understand exactly what the function needs as parameters. When working with two criteria (as Dave wants to do-year and week number), the syntax of the formula based on SUMIFS would look like this:

=SUMIFS(values_to_sum, years_to_compare, year_criterion,
weeks_to_compare, week_criterion)

In Dave’s description, what he has is a series of dates and a series of values related to those dates. The values_to_sum parameter is obviously from those values Dave has, but the years_to_compare and weeks_to_compare don’t exist in his data. Thus, they must be created in helper columns.

Let’s assume that column A contains Dave’s original dates and column B contains the values associated with those dates. In column C you can create the first helper column, using this formula in cell C2:


This assumes that row 1 contains headings for your data columns. The formula for the second helper column is placed in cell D2:


Copy these formulas down so that there is an associated year and week number for each date that appears in column A. With these helper columns in place, you have all the data pieces necessary to work with the SUMIFS function described earlier. What you still don’t have is an indicator of which year you want to extract from the values. This is easily remedied by placing a year into cell F2. Now the requested formula would appear as follows:


If you compare this formula to the syntax example provided earlier you’ll note that you have the values_to_sum (B:B), the years_to_compare (C:C), the year_criterion (F2), the weeks_to_compare (D:D), and finally the week_criterion. It is this last element which needs to be explained a bit; it looks like this:


Since the WEEKNUM function returns whatever weeknumber is appropriate for (in this case) today’s date, it may return something like “7”. Thus the week_criterion ends up looking like this:


This means that SUMIFS will only consider those week numbers in the data that are less than or equal to 7.

You might wonder if you can get rid of the helper columns. You cannot do so with SUMIFS. The reason is because the function expects data ranges upon which to do its comparisons, and those data ranges are calculated as the result of formulas in columns C and D.

As a final caveat to using this formula, you should understand precisely how you want to calculate your week number. In the examples in this tip, the simplest version of the WEEKNUM function was used, both in column D and in the SUMIFS formula. There are parameters that can be used with WEEKNUM to adjust how it works. In some instances you might want to calculate an ISO week number instead. More information on WEEKNUM and ISO week numbers can be found in these tips: