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
pwe5000
Frequent Visitor

Filtering to multiple date ranges at the same time

Hi,


I am using data from Google Analytics, and I would like to get data for the past 13 weeks, and the same period in the previous year. I want to filter out the dates between those two periods (in Power Query), in order to keep the size of the dataset as small as possible. I have been unable to determine how to filter to those two non-consecutive date ranges at the same time in Power Query.

 

The current filter applied is just getting all dates starting with the previous year's 13-week period until today:

 

#"Filtered Rows" = Table.SelectRows(#"Added Items", each Date.IsInPreviousNDays([Date], 475))

 

 

Instead of just everything from 475 days ago until today, I would like the past 100 days, and then also dates from 475 to 375 days ago. Any ideas?

2 ACCEPTED SOLUTIONS
alannavarro
Resolver I
Resolver I

Im not sure if it works the way you expect because of the way power query works with weeks but you could change that part.
=Table.SelectRows(#"Inserted Year", each Date.IsInPreviousNWeeks([Date], 13) or ( [Date] < Date.AddDays(Date.From(DateTime.LocalNow()),-365) and [Date] > Date.AddDays(Date.From(DateTime.LocalNow()),-465) ))

View solution in original post

wdx223_Daniel
Super User
Super User

#"Filtered Rows" = Table.SelectRows(#"Added Items", each Date.IsInPreviousNDays([Date], 100) or Date.IsInPreviousNDays(Date.AddDays([Date],-375), 100))

View solution in original post

2 REPLIES 2
wdx223_Daniel
Super User
Super User

#"Filtered Rows" = Table.SelectRows(#"Added Items", each Date.IsInPreviousNDays([Date], 100) or Date.IsInPreviousNDays(Date.AddDays([Date],-375), 100))
alannavarro
Resolver I
Resolver I

Im not sure if it works the way you expect because of the way power query works with weeks but you could change that part.
=Table.SelectRows(#"Inserted Year", each Date.IsInPreviousNWeeks([Date], 13) or ( [Date] < Date.AddDays(Date.From(DateTime.LocalNow()),-365) and [Date] > Date.AddDays(Date.From(DateTime.LocalNow()),-465) ))

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! Prices go up Feb. 11th.

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.

Jan NL Carousel

Fabric Community Update - January 2025

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