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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
threw001
Helper III
Helper III

Filtering Dates help in Power Query please!

Hi there,

 

I would like to set a filter on a date field in Power Query. The filter I would like to set is following:

Include all dates on or before 30 days from now.

For example if the date today is 02/10/2024. I would like to include all data with dates on or before 01/11/2024.

Thanks!

1 ACCEPTED SOLUTION

Hello @threw001 , 

 

Use the following M code to create the column for filtering, This code calculates the date 30 days before today

 

DateTime.LocalNow() - #duration(30, 0, 0, 0)

 

After creating this custom column, filter the date field by choosing dates that are less than or equal to the result of the formula

 

Table.SelectRows(#"Previous Step", each [Date] <= Date.From(DateTime.LocalNow() - #duration(30, 0, 0, 0)))

 

by this your data will dynamically filter to include all records with a date on or before 30 days from the current date, regardless of when the report is run

 

If you find this helpful , please mark it as solution which will be helpful for others and Your Kudos/Likes 👍 are much appreciated!

 

Thank You

Dharmendar S

LinkedIN 

 

 

View solution in original post

4 REPLIES 4
dharmendars007
Memorable Member
Memorable Member

Hello @threw001 , 

 

You can create the filter slicer using dates and set Relative Date style in the slicer settings, this should resolve your issue.

 

dharmendars007_1-1727848678114.png

 

 

dharmendars007_0-1727848610154.png

 

If you find this helpful , please mark it as solution which will be helpful for others and Your Kudos/Likes 👍 are much appreciated!

 

Thank You

Dharmendar S

LinkedIN 

 

 

Hello,

 

Thanks a lot for your help and apologies I had forgotten (but have now edited the original post) where I need to do this in Power Query as I have table mergers etc.

Hello @threw001 , 

 

Use the following M code to create the column for filtering, This code calculates the date 30 days before today

 

DateTime.LocalNow() - #duration(30, 0, 0, 0)

 

After creating this custom column, filter the date field by choosing dates that are less than or equal to the result of the formula

 

Table.SelectRows(#"Previous Step", each [Date] <= Date.From(DateTime.LocalNow() - #duration(30, 0, 0, 0)))

 

by this your data will dynamically filter to include all records with a date on or before 30 days from the current date, regardless of when the report is run

 

If you find this helpful , please mark it as solution which will be helpful for others and Your Kudos/Likes 👍 are much appreciated!

 

Thank You

Dharmendar S

LinkedIN 

 

 

@dharmendars007 thanks - that worked perfectly!

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

Fabric Community Sticker Design Challenge Barcelona Carousel

Fabric Community Sticker Challenge - Barcelona 2026

If you love stickers, then you will definitely want to check out our community sticker challenge, Barcelona edition!

July Power BI Update Carousel

Power BI Monthly Update - July 2026

Check out the July 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors