Filter BEFORE fixed date (Power Query)

adambc

Board Regular
Joined
Jan 13, 2020
Messages
177
Office Version
  1. 2019
  2. 2016
Platform
  1. Windows
I have built a Power Query that filters BEFORE today last year as follows, populating the 12 with a GetValue query that picks up a value from a named cell in the Workbook ,,,

Power Query:
[LastCompletedDate] < Date.AddMonths(DateTime.LocalNow(),-12)

... but it now appears that the REAL requirement (!) is a fixed date cut off, not a fixed period ie ...

Power Query:
[LastCompletedDate] < {a fixed date that has been entered into a named cell in the Workbook}

... 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) ...

Power Query:
[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 ...
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

Alex Blakenburg

Well-known Member
Joined
Feb 23, 2021
Messages
560
Office Version
  1. 365
Platform
  1. Windows
There are quite a few steps to this but they are pretty clear if you read this (its a link):-
Power Query Parameters – How to use Named Cells as Flexible Inputs (by Access Analytic)
It uses your exact same terminology of CutOffDate.

There is a warning about privacy setting but the article was written in May 2018 so I tried it without changing the settings and it seemed to work fine.
I tucked it away some time ago when I was looking at being able to use a cell to determine the data source for the query which is also covered in that same article.
 
Solution

Watch MrExcel Video

Forum statistics

Threads
1,129,380
Messages
5,635,918
Members
416,887
Latest member
SheriE

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
Top