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

Top Solution Authors
Top Kudoed Authors