Salesforce Reports support Relative Date Values for standard report filters. However, filtering by "Year to Date" (YTD) or "Last Year to Date" date ranges is not available as a single built-in relative value. To achieve these date ranges, you must combine two report filters and use Filter Logic. This article describes two options: using standard report filters with Filter Logic, or creating a custom Formula field on the Opportunities object.
This article outlines two approaches to filter a Salesforce Report for Year to Date (YTD) and Last Year to Date date ranges.
Step 1: Add 2 report filters for the current Year to Date
Step 2: Add 2 report filters for the previous Year to Date
Step 3: Combine these filters using Filter Logic
Another approach is to create a custom formula field on the Opportunities object that identifies whether a record's Close Date falls within the current or previous Year to Date range.
The formula evaluates two conditions:
The formula accounts for leap years by defaulting to February 28 when the current date is February 29.
Steps to create the custom field:
OR (
/* Check whether close date is YTD */
AND (
DATE ( YEAR ( TODAY() ), 1, 1 ) <= CloseDate,
CloseDate <= TODAY()
),
/* Check whether close date is YTD-1 */
AND (
DATE ( YEAR ( TODAY() )-1, 1, 1 ) <= CloseDate,
CloseDate <= IF (
/* Calculate TODAY()-1 YEAR, prevent trying to set last year to Feb 29th */
AND (
MONTH( TODAY() ) = 2,
DAY( TODAY() ) = 29
),
DATE( YEAR( TODAY() ) - 1, 2, 28),
DATE( YEAR( TODAY() ) - 1, MONTH( TODAY() ), DAY( TODAY() ) )
)
)
)
000388018

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.