Forum Discussion
Filter query by date column
- 8 years ago
This drives me nuts! I agree, I expect "is in the previous" to include the current month too.
However you can do what you want. First of all, on the dropdown menu at the top of the column, choose Date Filters/Month/This Month. This will give you a filter that filters out all the data from the current month. Next, go to the Applied Steps pane and click on the gear-shaped icon next to the newly-created Filtered Rows step. This opens up a dialog that allows you to edit the step. You'll see a condition that says "is in month" equals "this month"; underneath it select the Or radio button and then add a new condition that is "is in previous 5 months". It should look like this:
Click OK and you should be good.
HTH,
Chris
- 8 years ago
It's worth pointing out that this filter will return any dates that are in the current month but after today's date - which may not be what you want. I've written up this problem and a full solution in a blog post: https://blog.crossjoin.co.uk/2018/01/08/in-the-previous-date-filters-in-power-bi-gettransform-power-query/
Chris
This drives me nuts! I agree, I expect "is in the previous" to include the current month too.
However you can do what you want. First of all, on the dropdown menu at the top of the column, choose Date Filters/Month/This Month. This will give you a filter that filters out all the data from the current month. Next, go to the Applied Steps pane and click on the gear-shaped icon next to the newly-created Filtered Rows step. This opens up a dialog that allows you to edit the step. You'll see a condition that says "is in month" equals "this month"; underneath it select the Or radio button and then add a new condition that is "is in previous 5 months". It should look like this:
Click OK and you should be good.
HTH,
Chris
It's worth pointing out that this filter will return any dates that are in the current month but after today's date - which may not be what you want. I've written up this problem and a full solution in a blog post: https://blog.crossjoin.co.uk/2018/01/08/in-the-previous-date-filters-in-power-bi-gettransform-power-query/
Chris
- plerner8 years agoAdvocate I
That is a nice detail to think about.
- ppei8 years agoRegular Visitor
Chris,
I need to add a filter to my timestamp column to show only the previous 7 days (or one week) data. I read your blog and tried your solution. However, it didn't work for me. Mine didn't do any filter at all. My TimeOfSample column is data/time data type. It shows like this - 7/27/2018 12:00:55 AM. Is that special format that is the cause of not working? Do you know how I can resolve this problem?
Thanks in advance.
Pei
- cwebb8 years agoAdvocate V
Hi Pei,
Strange - so the filter did not remove any rows at all? Can you try creating a new column in the Query Editor with just the date values in, and applying the filter on that column?
Chris