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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Anonymous
Not applicable

How to filter/import data for the last week from today's date

Hi All,

 

I have a need to basically filter data that has a date field called 'created_at'. Basically I need to somehow filter data from today's date-7 days with respect to the 'created_at' date field. Also, today's date would be dynamic in nature so for example if today's date is 3/11/2022 then upon filtering data, it should display from 3/4 till today for the table that has 'created_at' field. Come tomorrow, it would be from 3/5-3/12 so it should have the ability to change today's date dynamically.  Can someone please suggest a solution in this case, thanks in advance. 

1 ACCEPTED SOLUTION
v-jingzhang
Community Support
Community Support

Hi @Anonymous 

 

If you only want to import last 7 days data into your model, @Vera_33 's solution will work. But this will not happen automatically. In Power BI Desktop, you need to click on Refresh button in Home ribbon to reimport the latest 7 days data. If you have published the report to Power BI Service, you should set a scheduled refresh for the dataset to refresh data every day. In this way, it will update the report to have latest 7 days data. 

 

You can also use the User Interface to filter rows based on date type column. Filter by values in a column - Power Query | Microsoft Docs

vjingzhang_0-1647338259875.png

 

If you want to load all data into the model but filter a date column on a visual (or on a report page, or on the whole report), you can use the relative date filter in filter pane or use relative date slicer. Use a relative date slicer or filter in Power BI - Power BI | Microsoft Docs This would update automatically every time you open the report. 

vjingzhang_1-1647338565808.png

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

View solution in original post

2 REPLIES 2
v-jingzhang
Community Support
Community Support

Hi @Anonymous 

 

If you only want to import last 7 days data into your model, @Vera_33 's solution will work. But this will not happen automatically. In Power BI Desktop, you need to click on Refresh button in Home ribbon to reimport the latest 7 days data. If you have published the report to Power BI Service, you should set a scheduled refresh for the dataset to refresh data every day. In this way, it will update the report to have latest 7 days data. 

 

You can also use the User Interface to filter rows based on date type column. Filter by values in a column - Power Query | Microsoft Docs

vjingzhang_0-1647338259875.png

 

If you want to load all data into the model but filter a date column on a visual (or on a report page, or on the whole report), you can use the relative date filter in filter pane or use relative date slicer. Use a relative date slicer or filter in Power BI - Power BI | Microsoft Docs This would update automatically every time you open the report. 

vjingzhang_1-1647338565808.png

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

Vera_33
Resident Rockstar
Resident Rockstar

Hi @Anonymous 

 

You want to filter the date prior to load to model using Power Query, right? Filter the [created_at] >= Date.AddDays( Date.From(DateTime.LocalNow()),-7)

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.