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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
Syndicate_Admin
Administrator
Administrator

Filter Power Query last 60 days

Can anybody help me?
I need to create a filter on Power Query with the last 60 days, considering the current date. Thanks.

1 ACCEPTED SOLUTION
v-yanjiang-msft
Community Support
Community Support

Hi @Syndicate_Admin ,

According to your description, here's my solution. Add a new step in Advanced editor.

Table.SelectRows(#"Changed Type", each Duration.Days(Date.From(DateTime.LocalNow())-[Date])<=60)

 Here's the whole code of my sample.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwMtI31DdUitWBcoyQOcbIHBNkjikyxwyZY47MsUDmWII4sQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}}),
    #"New"=Table.SelectRows(#"Changed Type", each Duration.Days(Date.From(DateTime.LocalNow())-[Date])<=60)
in
    #"New"

I attach my sample below for your reference.

 

Best Regards,
Community Support Team _ kalyj

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-yanjiang-msft
Community Support
Community Support

Hi @Syndicate_Admin ,

According to your description, here's my solution. Add a new step in Advanced editor.

Table.SelectRows(#"Changed Type", each Duration.Days(Date.From(DateTime.LocalNow())-[Date])<=60)

 Here's the whole code of my sample.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwMtI31DdUitWBcoyQOcbIHBNkjikyxwyZY47MsUDmWII4sQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}}),
    #"New"=Table.SelectRows(#"Changed Type", each Duration.Days(Date.From(DateTime.LocalNow())-[Date])<=60)
in
    #"New"

I attach my sample below for your reference.

 

Best Regards,
Community Support Team _ kalyj

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Vijay_A_Verma
Super User
Super User

You can use Date.IsInPreviousNDays

See the working here - Open a blank query - Home - Advanced Editor - Remove everything from there and paste the below code to test

if you want to remove records > 60 days

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("TchLCoAwDAXAu2TdB0nUti796xlK738NoYGQWU5rtFEiZVVwhWbqqdEeiq0OrwIpo06vDLW6QrHV7bVA6qjHa4ZavaHY6vOaICv1/gM=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Name = _t, Date = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Name", type text}, {"Date", type date}}),
    #"Filtered Rows" = Table.SelectRows(#"Changed Type", each Date.IsInPreviousNDays([Date], 60))
in
    #"Filtered Rows"

 If you want to remove records <60 days

then just put not

Table.SelectRows(#"Changed Type", each not Date.IsInPreviousNDays([Date], 60))

 👍 It's been a pleasure to help you | Help Hours: 11 AM to 9 PM (UTC+05:30)

How to get your questions answered quickly  -- How to provide sample data

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Kudoed Authors