cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
murali5431
Helper III
Helper III

Removal of rows having date 30 days before latest date using Power query

Hi,

 

I have  package information as below with their dates

 

PackageDate
ABCD12341-Sep-21
null1-Sep-21
ABCD12341-Sep-21
ABCD12349-Oct-21
ABCD12341-Oct-21
null10-Oct-21
ABCD12349-Oct-21
null10-Oct-21
null10-Oct-21
ABCD123410-Oct-21
MNOP567815-Sep-21
MNOP567820-Oct-21
null15-Sep-21
MNOP56781-Oct-21
MNOP567810-Oct-21
MNOP567810-Oct-21
null10-Oct-21
MNOP56781-Oct-21
null10-Oct-21
null10-Oct-21
MNOP567815-Sep-21
MNOP567810-Oct-21

 

I need assistance with how I can remove rows that are older than 30 days from current date (Current date - date in table > 30 should be deleted) while retaining null value rows, in Power query.

 

Thanks in advance!

Regards,

Muralidhar

1 ACCEPTED SOLUTION

= Table.SelectRows(#"Changed Type1", each [Package] = null or [Date] > Date.AddDays(DateTime.Date(DateTime.FixedLocalNow()),-30))
Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener work at KUMAVISION AG , one of the world's largest
implementation partners for Microsoft Dynamics. #
"Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast


View solution in original post

3 REPLIES 3
mwegener
Super User
Super User

Hi @murali5431 

 

this should work

= Table.SelectRows(#"Changed Type1", each [Date] > Date.AddDays(DateTime.Date(DateTime.FixedLocalNow()),-30))

 

 

Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener work at KUMAVISION AG , one of the world's largest
implementation partners for Microsoft Dynamics. #
"Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast


Thank you @mwegener 

 

Can you let me know how to retain the rows having "null" in column A. I believe that was not considered in the above query

= Table.SelectRows(#"Changed Type1", each [Package] = null or [Date] > Date.AddDays(DateTime.Date(DateTime.FixedLocalNow()),-30))
Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener work at KUMAVISION AG , one of the world's largest
implementation partners for Microsoft Dynamics. #
"Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast


Helpful resources

Announcements
PBI Sept Update Carousel

Power BI September 2023 Update

Take a look at the September 2023 Power BI update to learn more.

Learn Live

Learn Live: Event Series

Join Microsoft Reactor and learn from developers.

Top Solution Authors
Top Kudoed Authors