Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Filter Dates to only show current Day to next 3 years

I am trying to create a more dynamic date filter for a report of mine that shows past and predicted data. I would like a filter that only shows data related to the current day (Today) tp Next 3 years  to follow. For example from March3 2021 to March 3 2024. But I would like BI to be able to recognize what the current Day is so that when the next day begins it can automatically adjust the filter.

I am trying in date filters in Query editor as well but it's not working as expected.

 

Date.PNG

 

 

1 ACCEPTED SOLUTION
v-jingzhang
Community Support
Community Support

Hi @Anonymous 

You can click fx symbol beside the formula bar to add a step and paste below codes into the formula bar to filter the rows. "Changed Type" is name of the last step before you add this step. [Date] is the column which is filtered. Modify them according to your data.

= Table.SelectRows(#"Changed Type", each [Date] >= Date.From(DateTime.LocalNow()) and [Date] <= Date.AddYears(Date.From(DateTime.LocalNow()),3))

033002.jpg

 

Kindly let me know if this helps.
Community Support Team _ Jing
If this post helps, please Accept it as the solution to help other members find it.

View solution in original post

2 REPLIES 2
v-jingzhang
Community Support
Community Support

Hi @Anonymous 

You can click fx symbol beside the formula bar to add a step and paste below codes into the formula bar to filter the rows. "Changed Type" is name of the last step before you add this step. [Date] is the column which is filtered. Modify them according to your data.

= Table.SelectRows(#"Changed Type", each [Date] >= Date.From(DateTime.LocalNow()) and [Date] <= Date.AddYears(Date.From(DateTime.LocalNow()),3))

033002.jpg

 

Kindly let me know if this helps.
Community Support Team _ Jing
If this post helps, please Accept it as the solution to help other members find it.

amitchandak
Super User
Super User

@Anonymous , You can create a column like this in Dax and use that as filter

Is Today = if('Date'[Date]>=TODAY() && 'Date'[Date]<=date(Year(TODAY())+3,month(TODAY()),day(TODAY())),1,0)

 

or in power query

if [Date] >= DateTime.Date(DateTime.LocalNow()) && [Date] <= Date.AddYears(DateTime.Date(DateTime.LocalNow()),3) then 1 else 0

 

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.