Power Query dynamic previous months filter

571202

New Member
Joined
May 26, 2019
Messages
47
Hi all, how can I create a dynamic filter for 'previous months' but excluding last month, ie if it's currently October I want to filter for August and all previous months. Must be dynamic so that in November it filters for September and all previous months.
Is it possible to change the below code to suit?
Bash:
= Table.SelectRows(#"Sorted Rows", each Date.IsInPreviousMonth([Remedy Date Due]))

Thanks in advance.
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
My first thought - Why not exclude current month in the source / data load?

When I do this, I create a dynamic table with e.g. today(), transform it to a drilldown and load it as only connection.
Then I can use this variable in my source.

/Skovgaard
 
Upvote 0
My first thought - Why not exclude current month in the source / data load?

When I do this, I create a dynamic table with e.g. today(), transform it to a drilldown and load it as only connection.
Then I can use this variable in my source.

/Skovgaard
Hi @Skovgaard I have lots of other sheets with other filters so I can't delete the data because I need it for them.

I'm brand new to power query so I'm not sure what you mean in the rest of your post sorry.

Can I do what I need with the below filter?

1665042898079.png
 
Upvote 0
OK, I understand why you can't exclude them from the beginning then...

I haven't tried that filter before, so for me being able to help, I need an example of you dataset.
You can either use XL2BB or upload an image.

Or maybe other users can help you with this filter 😉

/Skovgaard
 
Upvote 0
Cross-posting (posting the same question in more than one forum) is not against our rules, but the method of doing so is covered by #13 of the Forum Rules.

Be sure to follow & read the link at the end of the rule too!

Cross posted at: Dynamic date filter - OzGrid Free Excel/VBA Help Forum
If you have posted the question at more places, please provide links to those as well.

If you do cross-post in the future and also provide links, then there shouldn’t be a problem.
 
Upvote 0
Unfortunately it gives me September...I only want August and earlier. Can I put a -1 in the formula somewhere?
 
Upvote 0
Power Query:
= Table.SelectRows(#"Sorted Rows", let dt = Date.AddMonths(Date.From(DateTime.LocalNow()),-1), yr = Date.Year(dt), mo = Date.Month(dt) in each [Remedy Date Due] < #date(yr,mo,1))
 
Upvote 0
Solution

Forum statistics

Threads
1,223,627
Messages
6,173,420
Members
452,514
Latest member
cjkelly15

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