cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
davehus Member
Member

Filter date table to Yesterday

Hi, I have a date table that I always want to filter to yesterday on a refresh. How to I adjust the M code to make this happen?

 

= Table.SelectRows(#"Changed Type2", each [DateKey] <= #date(2018, 4, 10))

 

Many thanks in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
vanessafvg Super Contributor
Super Contributor

Re: Filter date table to Yesterday

is this what you mean?

 

https://msdn.microsoft.com/en-us/query-bi/m/date-adddays

 

Date.AddDays(DateTime.FromText("2011-12-31"), -1)


Did I answer your question? Mark my post as a solution.
Proud a to be a Datanaut!

View solution in original post

2 REPLIES 2
vanessafvg Super Contributor
Super Contributor

Re: Filter date table to Yesterday

is this what you mean?

 

https://msdn.microsoft.com/en-us/query-bi/m/date-adddays

 

Date.AddDays(DateTime.FromText("2011-12-31"), -1)


Did I answer your question? Mark my post as a solution.
Proud a to be a Datanaut!

View solution in original post

davehus Member
Member

Re: Filter date table to Yesterday

Thank you, it was close to what I wanted. I ended it with

 

= Table.SelectRows(#"Changed Type2", each [DateKey] < DateTime.Date(DateTime.LocalNow()))

 

And it did the trick.. 🙂 

 

Helpful resources

Announcements
Ask Amanda Anything Q&A

Ask Amanda Anything Q&A

Learn the answers to some of the questions asked during the Amanda Triple A event.

October 2019 Community Highlights

October 2019 Community Highlights

October was a busy month in the community. Read the recap article to learn about some of the events and content.

New Solution Badges

New Solution Badges

Two waves of brand new solution badges are coming! Read the article for more information on our new community badges.

Analytics in Azure virtual event

Analytics in Azure virtual event

Experience a limitless analytics service built to ingest, prep, manage, and serve data for immediate use in Power BI.

Users Online
Currently online: 127 members 1,700 guests
Please welcome our newest community members: