Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
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?
Solved! Go to Solution.
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) ))
#"Filtered Rows" = Table.SelectRows(#"Added Items", each Date.IsInPreviousNDays([Date], 100) or Date.IsInPreviousNDays(Date.AddDays([Date],-375), 100))
#"Filtered Rows" = Table.SelectRows(#"Added Items", each Date.IsInPreviousNDays([Date], 100) or Date.IsInPreviousNDays(Date.AddDays([Date],-375), 100))
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) ))
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.