Formula Errors

Create an Excel RAG Status Formula Based on Date Differences

Muhammad TalhaMuhammad Talha Oct 21, 2026 870 views

Question details

The user needs a formula to generate a Red, Amber, or Green (RAG) status based on the number of days between start and end dates, specifically requiring blank end dates to return RED without being overridden.

How to Create an Excel RAG Status Formula for Date Differences
Product
Microsoft Excel
Device & OS
not provided
Scenario
Tracking project timelines or task deadlines where a visual RAG status must update automatically based on duration or missing completion dates.
Observed behavior
The current setup allows the 'under 30 days' (GREEN) logic to take precedence, preventing the formula from correctly displaying RED when the end date cell is completely blank.
Before you start

Ensure your start and end dates are formatted as valid dates rather than text, and identify the exact column letters you are referencing before constructing the formula.

Solution 1Recommended

Use a Priority-Based Nested IF Formula

Structure your nested IF formula to evaluate the blank end date condition first, preventing subsequent mathematical conditions from overriding it.

In Excel, an IF function evaluates conditions in the exact order they are written. When calculating date differences, a blank cell can sometimes be interpreted as zero, which inadvertently triggers 'less than 30 days' rules. By placing the blank check at the very beginning of the formula, it takes priority.

1
Select the target cell

Click on the cell in your status column where you want the RAG text (RED, AMBER, GREEN) to appear.

2
Input the nested IF formula

Type the formula: =IF(D2="","RED",IF(D2-C2<30,"GREEN",IF(D2-C2<60,"AMBER","RED"))). In this example, C2 is the Start Date and D2 is the End Date.

3
Apply to the column

Press Enter to save the formula. Click the cell again, grab the fill handle in the bottom-right corner, and drag it down to apply the logic to all relevant rows.

Use a Priority-Based Nested IF Formula
Formula Logic Explained: This formula first checks if D2 is empty; if true, it outputs RED and stops. If false, it checks if the duration is under 30 days for GREEN, then under 60 days for AMBER. Anything 60 days or over defaults to RED.
Master Data Tracking with WPS

Track Project Statuses Effortlessly with WPS Spreadsheet

WPS Office provides seamless support for advanced formulas like nested IFs and priority-based Conditional Formatting, making it incredibly easy to set up dynamic RAG tracking for any project schedule.

  1. 1. Open your tracker: Launch WPS Spreadsheet and open your project timeline document.
  2. 2. Input the RAG formula: Enter the nested IF formula checking for blank dates first into your status column.
  3. 3. Apply visual formatting: Use the Conditional Formatting tool found on the Home tab to automatically turn the output text into vibrant red, amber, and green cells.
Fully compatible with Microsoft Excel formulas and conditional formatting rules.Intuitive and user-friendly interface for managing complex data logic.Lightweight, fast, and completely free to download and use.Built-in templates for project management and timeline tracking.
microsoft office alternative - wps office

Frequently Asked Questions

Why does my formula return a #VALUE! error?

This usually occurs if the start or end date cells contain text instead of properly formatted dates. Ensure both columns are set to the 'Date' format and contain valid date entries.

Can I customize the RAG formula to use different day thresholds?

Yes, you can adjust the numerical values inside the formula. For example, change <30 to <15 if you want the GREEN status to apply only when the date difference is under 15 days.

What does the 'Stop If True' checkbox do in Conditional Formatting?

It instructs the spreadsheet program to stop evaluating any subsequent formatting rules once the current rule's condition is met. This is vital for preventing rule conflicts, such as an empty cell unintentionally triggering a 'less than 30' numerical rule.

How do I calculate working days only for my RAG status?

Instead of simply subtracting the dates (D2-C2), use the NETWORKDAYS(C2, D2) function inside your IF statement to exclude weekends from your 30-day and 60-day thresholds.