Time-Based Analysis
Swipe to show menu
Time-based reporting requires more than raw transaction dates. In this chapter, build dynamic monthly and year-to-date analytics that update automatically based on the current date.
Date Decomposition Functions
=MONTH(serial_number)
=YEAR(serial_number)
=TEXT(value, format_text)
MONTH(): returns the month number;YEAR(): returns the year;TEXT(): formats dates into readable labels.
TODAY Structure
=TODAY()
TODAY() returns the current system date dynamically.
EOMONTH Structure
=EOMONTH(start_date, months)
start_date: starting date;months: number of months shifted forward or backward.
Formula used in this chapter:
=EOMONTH(TODAY(),-1)
This safely returns a valid date from the previous month, even across year boundaries.
Confirm that Sales_Data[Date] contains valid Excel date values instead of text strings.
Inside Sales_Data, create the following columns:
Month
Year
Month_Year
Inside the first row of each column, type:
=MONTH([@Date])
=YEAR([@Date])
=TEXT([@Date],"MMM YYYY")
The dataset now contains reusable time dimensions for analysis.
Type:
=SUMIFS(Sales_Data[Revenue],Sales_Data[Month],MONTH(TODAY()),Sales_Data[Year],YEAR(TODAY()))
MONTH(TODAY()): current month;YEAR(TODAY()): current year.
The KPI now updates automatically as the calendar changes.
Type:
=COUNTIFS(Sales_Data[Month],MONTH(TODAY()),Sales_Data[Year],YEAR(TODAY()))
This counts all transactions from the current month and year.
Type:
=SUMIFS(Sales_Data[Revenue],Sales_Data[Month],MONTH(EOMONTH(TODAY(),-1)),Sales_Data[Year],YEAR(EOMONTH(TODAY(),-1)))
EOMONTH(TODAY(),-1): previous month reference;MONTH(...): previous month number;YEAR(...): correct year context.
The formula remains stable across month and year transitions.
Type:
=SUMIFS(Sales_Data[Revenue],Sales_Data[Year],YEAR(TODAY()),Sales_Data[Month],"<="&MONTH(TODAY()))
"<="&MONTH(TODAY()): dynamic comparison operator;- Includes all months up to the current month.
Add a transaction dated within the current month.
Confirm that:
- Current month Revenue updates automatically;
- Current month order count updates automatically;
- Year-to-date Revenue updates automatically.
1. Why do we split dates into Month and Year helper columns?
2. Why is EOMONTH preferred over subtracting 1 from MONTH(TODAY())?
3. What does the expression "<="&MONTH(TODAY()) allow in YTD calculations?
Thanks for your feedback!
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat