Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Can anybody help me?
I need to create a filter on Power Query with the last 60 days, considering the current date. Thanks.
Solved! Go to Solution.
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.
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.
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
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.