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.
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) ))
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.