Function Problems

How to Count Values Below a Limit During the Last Six Months in Excel

Olivia MillerOlivia Miller Nov 10, 2026 868 views

Question details

The user needs to count specific numeric values (such as drug levels) that fall below a designated threshold within a rolling six-month timeframe using Excel formulas.

How to Count Values Below a Limit During the Last Six Months in Excel
Product
Excel
Device & OS
not provided
Scenario
Filtering and counting dataset records based on a dynamic rolling date range and a specific numerical criteria.
Observed behavior
To achieve accurate results, a rolling six-month period must be calculated dynamically rather than using a fixed 180-day interval, alongside counting instances that meet the numeric condition.
Before you start

Ensure that your date column contains valid Excel dates and that the values you want to evaluate are formatted as numbers, rather than text strings.

Solution 1Recommended

Use COUNTIFS and EDATE to Count Records

The most accurate way to filter records over a rolling six-month period and apply a numeric threshold is by combining the COUNTIFS, EDATE, and TODAY functions.

The COUNTIFS function allows you to apply multiple criteria to your data. By combining it with EDATE and TODAY, you can dynamically establish a start date exactly six calendar months ago.

1
Select the destination cell

Click on the empty cell where you want the final count to be displayed.

2
Enter the COUNTIFS formula

Type the formula =COUNTIFS(Table1[Date], ">="&EDATE(TODAY(), -6), Table1[DrugLevel], "<=2.3"). Replace 'Table1[Date]' and 'Table1[DrugLevel]' with your actual cell ranges, and '2.3' with your specific threshold.

3
Apply the formula

Press Enter. The cell will calculate and display the total number of records from the last six months where the value is 2.3 or less.

Use COUNTIFS and EDATE to Count Records
Why use EDATE instead of subtracting days?: Using EDATE(TODAY(), -6) calculates exactly six months prior to today's date, accounting for different month lengths (28 to 31 days). This is significantly more accurate than simply subtracting 180 days.
Free Microsoft Office alternative

Easily Manage Advanced Formulas with WPS Office

WPS Spreadsheet provides seamless compatibility with Excel formulas, including COUNTIFS, EDATE, and TODAY, allowing you to perform complex data analysis efficiently and for free.

  1. 1. Open your dataset: Launch WPS Spreadsheet and open the file containing your dates and numeric values.
  2. 2. Input the formula: Select an empty cell and type the exact same =COUNTIFS formula as you would in Microsoft Excel.
  3. 3. Calculate the result: Press Enter to instantly process your rolling six-month data and view your calculated results.
Fully compatible with Microsoft Excel (.xlsx) files and formula syntaxes.Lightweight and runs smoothly on Windows, Mac, and Linux environments.Built-in error checking to easily spot text-formatted numbers and dates.Free to download and use with a highly familiar, intuitive user interface.
microsoft office alternative - wps office

Frequently Asked Questions

Can I use TODAY()-180 instead of the EDATE function?

While TODAY()-180 works as a rough estimate, it isn't strictly accurate for a six-month period because calendar months vary in length. EDATE(TODAY(), -6) dynamically calculates the exact date six calendar months ago regardless of leap years or 31-day months.

How do I change the formula to count values above the limit instead?

Simply modify the logical operator inside the quotation marks. For example, change "<=2.3" to ">2.3" in the COUNTIFS criteria argument to count values strictly greater than your threshold.

Why is my COUNTIFS formula returning a #VALUE! error?

A #VALUE! error usually occurs if the ranges provided in the COUNTIFS formula are not exactly the same size. Ensure that your date range (e.g., A2:A100) and your numeric value range (e.g., B2:B100) contain the exact same number of rows.

Does WPS Spreadsheet fully support the EDATE function?

Yes, WPS Spreadsheet natively supports the EDATE, TODAY, and COUNTIFS functions. You can use the exact same formulas and syntax as you do in Microsoft Excel without any modifications.