cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper II
Helper II

How to use "Filter Rows" for a Date column to filter $Today - 30 days?

I have a Folder Source with a bunch of CSVs that goes into this folder automatically, but inside Power BI I just want to load the newest CSVs, where newsest = Today - 30 days. How can I do that? The column Date corresponds to the "Creation date" of the CSV.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

Nice, using your answer as foundation, I found an even easier solution:

 

Capture.PNG

 

#"Filtered Rows" = Table.SelectRows(Source, each Date.IsInPreviousNDays([Date created], 30) or Date.IsInCurrentDay([Date created]))

 

View solution in original post

4 REPLIES 4
Highlighted

Hi,

 

You need to load all the CSVs which are created within the last 30 days.

 

Or only one CSV which has been created exactly 30 days before Today ?

Highlighted

The folder will have all the CSVs since forever, but inside Power BI I just want to load and work with the CSVs which were created inside the frame "today - 30 days".

 

Capture.PNG

 

2.PNG

 

This is where I can filter, but I don't know how to express "today - 30 days" or something with the same effect in there.

Highlighted

You could use the 'is in the previous' menu with 30 days as a parameter. This will however not consider the csv of 'Today'.

 

Copy paste this code in the advanced editor (M) and adapt it to your need (update the source path).

 

let
Source = Folder.Files("YourSourcePath"),
DatesFlag = Table.AddColumn(Source, "Flag", each [Date created] <= DateTime.LocalNow() and [Date created] >= Date.AddDays(DateTime.LocalNow(),-30)),
KeepLast30Days = Table.SelectRows(DatesFlag, each ([Flag] = true))
in
KeepLast30Days

You can then peacefully combine the binaries (Column 'Content').

 

Highlighted

Nice, using your answer as foundation, I found an even easier solution:

 

Capture.PNG

 

#"Filtered Rows" = Table.SelectRows(Source, each Date.IsInPreviousNDays([Date created], 30) or Date.IsInCurrentDay([Date created]))

 

View solution in original post

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Community Conference

Microsoft Power Platform Communities

Check out the Winners!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors