cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
JRHans09
Resolver II
Resolver II

Date is in the next 30 days

I am trying to filter the date range in PowerQuery to show the dates in the next 30 days, including today. Date field is called: dd-date

 

I have tried:

 

 

Table.SelectRows(#"Filtered rows 1", each [#"dd-date"] >= DateTime.LocalNow() and [#"dd-date"] <= ( DateTime.LocalNow() + 30))

 

Error message:  something about not possible to use '>' in date functions
 

 

Table.SelectRows(#"Filtered rows 1", Date.IsInNextNDays(Date.AddDays(DateTime.FixedLocalNow(), 1), 30)​

 

Error message: We cannot convert the value true to type Function.
 
How do I filter the date range to be in the next 30 days (including today)?
 
Sorry, I am sure there is a simple solution to this, but I am very inexperienced in M.
 
Thanks for you help.
1 ACCEPTED SOLUTION

Please try this expression instead, confirming the name of your previous step and your date column name.  Just replace the line you showed with this in the Formula Bar.  You can auto generate this line by using the pull-down filter on your date column, choose Date Filters, and "In the Next".

 

= Table.SelectRows("Filtered Rows 1", each Date.IsInNextNDays([dd-date], 30))

 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

3 REPLIES 3
JRHans09
Resolver II
Resolver II

I just tried this and receive a Timeout error:

Table.SelectRows(#"Filtered rows 1", each [#"dd-date"] = Date.IsInNextNDays(Date.AddDays(DateTime.FixedLocalNow(), 1), 14))
Reduced to 14 days to see if the data would load.
 
Thanks.

Please try this expression instead, confirming the name of your previous step and your date column name.  Just replace the line you showed with this in the Formula Bar.  You can auto generate this line by using the pull-down filter on your date column, choose Date Filters, and "In the Next".

 

= Table.SelectRows("Filtered Rows 1", each Date.IsInNextNDays([dd-date], 30))

 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

No code errors now, but continue to receive a timeout error.

 

Thanks for your help.

Helpful resources

Announcements
PBI_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Get Ready for Power BI Dev Camp

Microsoft named a Leader in The Forrester Wave

Microsoft received the highest score of any vendor in both the strategy and current offering categories.

Get Ready for Power BI Dev Camp

Power BI Dev Camp - September 30th, 2021

Mark your calendars and join us for our next Power BI Dev Camp!

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Top Kudoed Authors