Filter BEFORE fixed date (Power Query)

adambc

Active Member
Joined
Jan 13, 2020
Messages
412
Office Version
  1. 365
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

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
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.
 
Upvote 0
Solution

Forum statistics

Threads
1,223,727
Messages
6,174,146
Members
452,547
Latest member
Schilling

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