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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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


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

 

Thanks for your help.

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors