Using Excel formulae to filter and sum rows

Bikhod Khan 30 Reputation points
2024-02-02T13:43:10.4733333+00:00

Hi, In reference to the example table below, how can I use Excel formulae to calculate Total Units Sold, with today's date as the starting date from which to count backwards:

Last 3 working days i.e. January 9, 8, 5
Last 7 working days i.e. January 9, 8, 5, 4, 3, 2, and December 29

Please note that I want to exclude Weekend (Sat & Sun) and public holidays.

I also need the same totals, but without excluding any days i.e.

Last 3 days i.e. 9, 8, 7
Last 7 days i.e. 9, 8, 7, 6, 5, 4, 3

I know I can use Slicers and Column filters and or Pivot Tables. But, I want the formulae so I can add a new table above the table below that shows all the above calculations without requiring the user to filter anything manually. The new table would have four rows - please see attached image.

Screenshot 2024-02-02 135241.png

Excel
Excel
A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
2,175 questions
0 comments No comments
{count} votes

Accepted answer
  1. Barry Schwarz 3,731 Reputation points
    2024-02-02T22:05:11.4166667+00:00

    You will need a list of holidays. The WORKDAY function will calculate the date of the N-th workday before a start date when you specify N-1. For your example, if today were 9 January 2024, the formulas

    • SUMIF(A9:A20,">="&WORKDAY(TODAY(),-2,holiday-dates),B9:B20)
    • SUMIF(A9:A20,">="&WORKDAY(TODAY(),-6,holiday-dates),B9:B20)

    would do what you want for workdays.

    For total days, the criteria is simply ">="&TODAY()-2 or ">="&TODAY()-6

    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Bikhod Khan 30 Reputation points
    2024-02-02T13:54:21.9133333+00:00

    Screenshot 2024-02-02 135241.png

    The formatting of the above question went wrong and I am unable to correct it. Also, the example assumes today is 9 January 2024 (because I wanted a range with a weekend and public holiday)

    The attached image shows what I am trying to create in Excel.

    0 comments No comments

  2. Bikhod Khan 30 Reputation points
    2024-02-03T12:34:42.29+00:00

    Thank you Barry :-)

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.