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
mork
Helper V
Helper V

Filter rows in query editor up to current date

I have a table that includes a column with the date of the first day of each week for the whole 2016. I want to filter the rows of that table inside query editor in a way that it will keep only the rows up to the current date.

How can I do that inside the query editor?

1 ACCEPTED SOLUTION
KHorseman
Community Champion
Community Champion

Short of typing in all the code in the advanced editor yourself...

 

Hit the filter dropdown on the column and go to Date Filters, pick "Before...", then in the input box that pops up change that to "is before or equal to..." Type in today's date or whatever arbitrary date (this is just to get the editor to give you the code. You'll change this in a moment so the date doesn't really matter) and hit enter.

 

Now go to the formula bar. You should see something that looks like:

= Table.SelectRows(#"Replaced Value", each [startdate] <= #date(2016, 5, 9))

Replace the date part of that with Date.From(DateTime.LocalNow())

 

= Table.SelectRows(#"Replaced Value", each [startdate] <= Date.From(DateTime.LocalNow()))

Now your query will always be filtered to the current day or earlier.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

3 REPLIES 3
KHorseman
Community Champion
Community Champion

Short of typing in all the code in the advanced editor yourself...

 

Hit the filter dropdown on the column and go to Date Filters, pick "Before...", then in the input box that pops up change that to "is before or equal to..." Type in today's date or whatever arbitrary date (this is just to get the editor to give you the code. You'll change this in a moment so the date doesn't really matter) and hit enter.

 

Now go to the formula bar. You should see something that looks like:

= Table.SelectRows(#"Replaced Value", each [startdate] <= #date(2016, 5, 9))

Replace the date part of that with Date.From(DateTime.LocalNow())

 

= Table.SelectRows(#"Replaced Value", each [startdate] <= Date.From(DateTime.LocalNow()))

Now your query will always be filtered to the current day or earlier.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




You Sir are a hero among men. This worked for me I was doing a filter in the Query to get data for each date >= TodaysDate

Replace the date part of that with Date.From(DateTime.LocalNow())

 

= Table.SelectRows(#"Replaced Value", each [startdate] <= Date.From(DateTime.LocalNow()))

Now your query will always be filtered to the current day or earlier.


 

To the current day and time, to be precise.

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.