Forum Discussion
Relative Date X Days Before
- 7 years ago
I'm guessing that you have Date column in Datetime format. In "M", it is important to match data type for both left and right of the operator.
Then change it to...
= Table.SelectRows(#"Changed Type", each [Date] < Date.AddDays(DateTime.LocalNow(),-30))
I'd do this in query editor.
Once data is brought in, apply 'date is before' filter using any date.
Then in advanced query editor, find the Filtered row step just applied.
It will look like...
#"Filtered Rows" = Table.SelectRows(#"Changed Type", each [Date] < #date(2018, 10, 1))
Now replace #date() part with dynamic calculation.
Something like....
#"Filtered Rows" = Table.SelectRows(#"Changed Type", each [Date] < Date.AddDays(DateTime.Date(DateTime.LocalNow()),-30))
Edit: You can parameterize -30 part if desired.
I tried your suggestion and got this error
Expression.Error: We cannot apply operator < to types Date and DateTime.
- Chihiro7 years agoSolution Sage
I'm guessing that you have Date column in Datetime format. In "M", it is important to match data type for both left and right of the operator.
Then change it to...
= Table.SelectRows(#"Changed Type", each [Date] < Date.AddDays(DateTime.LocalNow(),-30))
- fletch85277 years agoNew Member
Awesome, Thanks! I was just reading about that and noticed I had a DateTime field. Thanks for the fast replies. Still trying to get my head wrapped around this stuff. So much more involved that a tabel in Excel ;)