Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by attending the DP-600 session on April 23rd (pacific time), live or on-demand.
Learn moreNext up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now
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!
Solved! Go to 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
Hello @threw001 ,
You can create the filter slicer using dates and set Relative Date style in the slicer settings, this should resolve your issue.
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
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
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
| User | Count |
|---|---|
| 47 | |
| 44 | |
| 39 | |
| 20 | |
| 15 |
| User | Count |
|---|---|
| 68 | |
| 68 | |
| 31 | |
| 27 | |
| 24 |