Filter for BEFORE today last year ...

adambc

Active Member
Joined
Jan 13, 2020
Messages
368
Office Version
  1. 2019
  2. 2016
Platform
  1. Windows
I want to turn this ...

Power Query:
= Table.SelectRows(#"Changed Type", each [LastCompletedDate] < DateTime.LocalNow() or [LastCompletedDate] = null)

... to select rows < TODAY LAST YEAR or = null ...

(ie DateTime.LocalLastYear()!!!)

I've found a few ideas in this forum (and others) but can't seem to get any of them to work!

Can anyone help please?

Many thanks ...
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
I've worked it out!!!

= Table.SelectRows(#"Filtered Rows", each [LastCompletedDate] < Date.AddDays(DateTime.LocalNow(),-365) or [LastCompletedDate] = null)

... unless I've missed something?
 
Upvote 0
For Leap Years you have Problems Use this.
Power Query:
= Table.SelectRows(#"Filtered Rows", each [LastCompletedDate] < Date.AddMonths(DateTime.LocalNow(),-12) or [LastCompletedDate] = null)
 
Upvote 0
Solution
@maabadi

Hopefully no-one will object to me asking a very closely linked follow up question here?

It now appears that the REAL requirement (!) is a fixed date cut off, not a fixed period! - if I wanted to amend ...

VBA Code:
[LastCompletedDate] < Date.AddMonths(DateTime.LocalNow(),-12)

... to ...

VBA Code:
[LastCompletedDate] < {[I]a fixed date that has been entered into a named cell in the Workbook[/I]}

... how would I code that?

I know what the syntax looks like if I use a Power Query date filter ie (for 1/4/2020) ...

VBA Code:
[LastCompletedDate] < #datetime(2020, 4, 1, 0, 0, 0)

... but how would I turn eg 1/4/2020 entered into the named cell in the Workbook into the correct syntax ie (2020, 4, 1, 0, 0, 0)?

Thanks ...
 
Upvote 0
Please start new thread And ask there. I don't familiar with power query formulas completely.
 
Upvote 0

Forum statistics

Threads
1,214,590
Messages
6,120,423
Members
448,961
Latest member
nzskater

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top