Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics 365 | Integration, Dataverse...
Suggested answer

View using date filter last x (5) years. How do you include start of the calender year?

Posted on by 15

Hi,

I have a table view where I need to show data for the last 5 years.

Using last-x-years only includes up to the date time from today (EG 09-20-2016 - 09-20-2021).

How do you filter to include the start of the calendar year (EG 01-01-2016 - 09-20-2021)?

I assumed this was a common scenario but I haven't been able to work it out.

This is for a standard table view filter so I'm looking for a static fetchxml solution instead of computing the exact dates myself in a script/code.

This is for Dynamics 365 Sales.

Thanks for your help!

  • Suggested answer
    CRMJetty Profile Picture
    CRMJetty 3,508 on at
    RE: View using date filter last x (5) years. How do you include start of the calender year?

    Hello Sub,

    I suggest you to implement fiscal periods. You can Filter out records more than one year.

    for more clarification, you can refer this image

    Blog-Image-2.png

  • Suggested answer
    Nya Profile Picture
    Nya 29,056 on at
    RE: View using date filter last x (5) years. How do you include start of the calender year?

    Hi,

    There is no OOTB operator can achieve your request.

    Please refer to the following post:

    (+) Date and Time operators in CRM Explained - Microsoft Dynamics CRM Community

    If you need to show data for the last year (EG 01-01-2020 - 09-20-2021), it can be achieved with "last-year" operator easily.

    pastedimage1632127531539v1.png

    But it cannot filter out the data for over 1 year.

    You have to set the filter with fixed value.

    pastedimage1632127786016v2.png

    As the Created On field will be populated automatically with the created date (won't be empty), you only need to set this one condition to filter the records from the beginning of the year 5 years ago to the present.

     

    Or maybe you can create a custom field, calculate the first day of that year five years ago and set it as the value of the field.

    Then set it as a condition in FetchXML, but it won't be as easy as filtering with the fixed date and is not recommended.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans