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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

Reply
Anders_G
Helper I
Helper I

Filter by same period last year (data import)

I connect to a data set that is very heavy, so I have to limit each data import to the previous 30 days. 

 

I do one data import for the previous 30 days this year using the standard date filters. I also want to do a separate data import for the same 30 days last year. It's the data import from last year that I haven't figured out how to do. Any suggestions?

 

Query 1 : 2022/11/08 - 2022/10/10

Query 2 : 2021/11/08 - 2021/10/10

 

Thank you!

 

3 REPLIES 3
v-yiruan-msft
Community Support
Community Support

Hi  @Anders_G ,

What data source you are connecting to? Please check if  Power Query Parameter can help you achieve the requirement.

1. Handle with filtering when load the data

Include Parameters within Power BI to Query a SQL Data Source

(x as text, y as text)=>let
    Source = Sql.Database("x", "y", [Query="select *#(lf)from z#(lf)WHERE [period_number]="&P2&"#(lf)AND [fiscal_year]="&P1&""])
in
    Source

2. Filter the rows after the data loaded

Using Query Parameters in Filter Rows

yingyinr_0-1668152028617.pngBest Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
amitchandak
Super User
Super User

@Anders_G , You can get 4 dates like this in power query and use that to filter data

 

Date.From(DateTime.LocalNow())


Date.AddDays(Date.From(DateTime.LocalNow()),-30)

 

Date.AddYears(Date.From(DateTime.LocalNow()),-1)


Date.AddYears(Date.AddDays(Date.From(DateTime.LocalNow()),-30),-1)

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Thank you. But where exactly do I add this? 

Helpful resources

Announcements
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

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