Excel allows us to sum the values based on the weekday by using SUMPRODUCT and WEEKDAY functions. This step by step tutorial will assist all levels of Excel users in summarizing the values based on the weekday.
Figure 1. Sum Amount by Weekday
Syntax of the SUMPRODUCT Formula for Summing With Criteria
=SUMPRODUCT(--(Criteria_range=Criteria)*Sum_Range)
The parameters of the SUMPRODUCT function for summing with criteria are:
- Criteria_range – a cell range where we check if the criterion is met
- Criteria – a criterion for summing the data
- Sum_Range – a cell range to sum the data
Syntax of the WEEKDAY Formula
=WEEKDAY(date,[return_type])
The parameters of the WEEKDAY function are:
- date – date value from which we want to get the weekday
- return_type – indicates the start day of the week (1- week starts from Sunday to Saturday, 2-weeks starts from Monday to Sunday)
Setting up Our Data for Summing by Weekday
Our first table consists of 2 columns: “Payment date” (column B) and “Amount” (column C). The second one has three columns: “Weekday” (Column E), “Helper column” (Column F) and “Amount per Weekday” (Column G). The idea is to summarize the values from the column “Amount” based on the Weekday and to place the result in the column G.
Figure 2. Table structure for summarizing the “Amount” values by Weekday
SUM by Weekday Using SUMPRODUCT and WEEKDAY Function
We want to get the total amount from column C based on the Weekday in column F. In order to make the formula more clear, we will create a named range Date for cell range B3:B12 and Amount for cell range C3:C11.
To create a named range we should follow the steps:
- Select the cell range that should be named
- Click on the name box in Excel
- Write the name for the cell range and press enter
Figure 3. Creating a named range Date for column “Payment date”
Figure 4. Creating a named range Amount for column “Amount”
The formula for summarizing the values based on weekdays looks like:
=SUMPRODUCT((WEEKDAY(Date,2)=F3)*Amount)
The criteria_range in the SUMPRODUCT function is the formula part WEEKDAY(Date,2) while the criteria is the weekday number in the cell F3. Sum_range is named range Amount. In WEEKDAY function date is a named range Date, while the return_type is 2.
To apply the SUMPRODUCT function we need to follow these steps:
- Select cell G3 and click on it
- Insert the formula:
=SUMPRODUCT((WEEKDAY(Date,2)=F3)*Amount)
- Press enter
- Drag the formula down to the other cells in the column by clicking and dragging the little “+” icon at the bottom-right of the cell.
Figure 5. Sum by Weekdays using SUMPRODUCT and WEEKDAY function
Formula WEEKDAY(Date,2 ) converts each date from the Date named range to the weekday number: {2;2;6;2;5;4;6;6;1}
.
This array is then compared with the value 1 from the cell F3. Values in the “Helper column” represent the days in the week. Output array after comparison looks like: {FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;TRUE}
.
Array values from the WEEKDAY function are then multiplied with the values from the Amount named range creating a new array:
{0;0;0;0;0;0;0;0;7600}
The final result is the number 7600, a sum of all final array numbers.
Most of the time, the problem you will need to solve will be more complex than a simple application of a formula or function. If you want to save hours of research and frustration, try our live Excelchat service! Our Excel Experts are available 24/7 to answer any Excel question you may have. We guarantee a connection within 30 seconds and a customized solution within 20 minutes.
Leave a Comment