How to Use COUNTIF with WEEKDAY in Excel (3 Methods)

countif weekday


Dataset Overview

Let’s say we have data from a supermarket that includes the staff’s duty schedule. In this example, we’ll explore how to use the COUNTIF and WEEKDAY functions in Excel based on this dataset. Additionally, we’ve included a table showing the days and their corresponding serial numbers. We’ll assume that the week starts on Monday (marked as 1) and proceed accordingly.

Dataset for Using COUNTIF with WEEKDAY


Method 1 – Count Weekday Using the COUNTIF Function

The COUNTIF function counts the number of cells in a range that match a specific criterion. Its syntax is as follows:

=COUNTIF(range, criteria)
  • range: The cell range where the criterion will be applied for counting.
  • criteria: The condition for which the search will be performed.

This function has been available in Excel since version 2007.

Dataset for Using COUNTIF to Calculate the Number of Weekday

Steps:

  • Select the cell where you want to determine the weekday (e.g., Cell D5).
  • In Cell D5, enter the following formula:
=TEXT(C5,"dddd")
    • This formula uses the TEXT function, with C5 as the value and “dddd” as the format_text. It returns the day of the week in the specified format.

Using TEXT Function to Determine Weekday

  • Press Enter.

Getting Weekday from TEXT Function

  • Drag the Fill Handle to copy the formula to other cells.

Dragging Fill Handle to Copy Formula

  • The weekdays are displayed.

Final Output from Text Function

  • To calculate the total number of a specific weekday (e.g., Sunday), select the cell where you want the result and enter the following formula:
=COUNTIF(D5:D13,D15)

In this formula:

  • D5:D13 represents the cell range.
  • D15 is the criteria (Sunday in this case).

Counting Weekday with COUNTIF Function in Excel

  • Press Enter to get the result.

Getting Result from COUNTIF Function

Read More: COUNTIF vs COUNTIFS in Excel


Method 2 – Using the COUNTIFS Function for Weekdays with Conditions

The COUNTIFS function is a statistical function that counts the number of times all specified conditions are met. Its syntax is as follows:

=COUNTIFS(criteria_range1, criteria1, [criteria_range2, criteria2]…)

Here:

  • criteria_range1: The first range to evaluate.
  • criteria1: Can be a number, text, or cell reference.
  • [criteria_range2, criteria2]: Optional additional criteria pairs (up to 127 pairs).

This function has been available in Excel since version 2007. 

Example Problem:

Suppose we want to determine if an employee named Frank worked on a Saturday. We’ll use the COUNTIFS function to check the weekday and return the result as either True or False.

Steps:

  • Determine the weekdays in the Day column using the steps from Method 1.

Dataset for Employing COUNTIFS Function

  • Select the cell where you want the outcome (e.g., Cell D17).
  • In Cell D17, enter the following formula:
=IF(COUNTIFS(D5:D13,D15,B5:B13,D16),"True","False")

Here:

    • The COUNTIFS function checks if any cell matches both criteria (D15 for the weekday and D16 for the employee’s name).
    • If the logical test is TRUE, the formula returns True; otherwise, it returns False.

Applying COUNTIFS Function for Weekday with Condition

  • Press Enter to get the Outcome.

Getting Outcome from COUNTIFS Function


Method 3 – Combine the WEEKDAY Function with Other Excel Functions

The WEEKDAY function in Excel returns the day of the week corresponding to a given date. By default, it provides an integer value ranging from 1 (Sunday) to 7 (Saturday). The syntax for this function is as follows:

=WEEKDAY(serial_number,[return_type])

Here:

  • serial_number: A sequential number representing the date you want to analyze.
  • return_type: A number that determines the type of return value.

This function has been available in Excel since version 2007.

In this section, we’ll explore how to use the WEEKDAY function in combination with other functions to meet specific criteria. We’ll refer to the serial number of days provided in the dataset. The WEEKDAY function will compare the date with the day-wise serial number. Let’s assume we’re interested in checking if a specific day (e.g., Saturday) corresponds to a particular employee (e.g., Frank). Here are the steps:

Dataset for Employing COUNTIFS Function

Steps:

  • Select the cell where you want to display the outcome.
  • Enter the following formula in that selected cell:
=IF(SUMPRODUCT((WEEKDAY(B5:B13,2)=C17)*(C5:C13=C18)),"True","False")

Here:

  • B5:B13 represents the range of dates.
  • C17 corresponds to the day (e.g., Saturday).
  • C5:C13 represents the range of employee names.
  • C18 corresponds to the specific employee (e.g., Frank).

Combining WEEKDAY Function with Other Excel Functions

  • Press Enter.

Getting Outcome from Weekday Function

How Does the Formula Work?

  • WEEKDAY(B5:B13, 2) = C17: This part of the formula checks if the day of the week for each date in the range matches the specified day (Saturday). If the condition is met, it returns True; otherwise, it returns False.
  • C5:C13 = C18: Similarly, this part checks if the employee’s name matches the specified name (Frank).
  • SUMPRODUCT((WEEKDAY(B5:B13, 2) = C17) * (C5:C13 = C18)): The entire formula evaluates to 1 if both conditions are satisfied; otherwise, it evaluates to 0.
  • IF(SUMPRODUCT(…), “True”, “False”): Finally, the IF function returns True if the sum of products is 1 (i.e., both conditions are met) and False otherwise.

Practice Section

We have provided a practice sheet for you to practice using the COUNTIF function with the WEEKDAY function in Excel.

Practice Section for Using COUNTIF with WEEKDAY


Download Practice Workbook

You can download the practice workbook from here:


Related Articles

Get FREE Advanced Excel Exercises with Solutions!
Alok Paul
Alok Paul

Alok Paul has completed his B.Sc. in Electronics and Telecommunication Engineering from East West University. He has been working on the ExcelDemy project for more than 2 years. He has written 220+ articles and replied to numerous comments. He is experienced in Microsoft Office, especially in Excel. He also led some teams on Excel and VBA content development. He has a keen interest in Advanced Excel, Data analysis, Excel Pivot Table, Charts, and Dashboard. He loves to research... Read Full Bio

We will be happy to hear your thoughts

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo