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

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.

Reply
JChris
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

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

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 ?

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.

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').

 

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]))

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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