Forum Discussion
Power Query Rolling Date Range
- Anonymous4 years ago
I would make two separate queries for the dates, then just use them as variables. Start a blank query named BeginDate, and in the formula bar, type:
= #date(2016,7,1)
Then another blank query, named EndDate, and in the formula bar, type:
= if Month.From(DateTime.LocalNow()) > 6 then Date.AddMonths(Date.StartOfYear(DateTime.LocalNow()), 6) else Date.AddMonths(Date.AddYears(Date.StartOfYear(DateTime.LocalNow()), -1), 6)
Now you can go back to your original table, and chance your filter to:
Table.SelectRows(Source, each [Date] >= BeginDate and [Date] <= EndDate)
--Nate
I would make two separate queries for the dates, then just use them as variables. Start a blank query named BeginDate, and in the formula bar, type:
= #date(2016,7,1)
Then another blank query, named EndDate, and in the formula bar, type:
= if Month.From(DateTime.LocalNow()) > 6 then Date.AddMonths(Date.StartOfYear(DateTime.LocalNow()), 6) else Date.AddMonths(Date.AddYears(Date.StartOfYear(DateTime.LocalNow()), -1), 6)
Now you can go back to your original table, and chance your filter to:
Table.SelectRows(Source, each [Date] >= BeginDate and [Date] <= EndDate)
--Nate
- jguercio4 years agoFrequent Visitor
I had to make a minor adjustment:
Table.SelectRows(Source, each [Period] >= Date.From( BeginDate ) and [Period] <= Date.From( EndDate))but otherwise it worked!