Reply
Highlighted
Frequent Visitor
Posts: 4
Registered: ‎01-05-2018
Accepted Solution

Filter query by date column

I am trying to reduce the amount of rows that Power BI querys from the database, so in the query editor I am adding a filter on a timestamp column from the data source. In the filter options i have choosen "is in the previous", and then selected 6 "months". It appears to calculate first which where the 6 previous months, leaving the current one out, and then it brings the data that belongs to them, but this leaves out all rows from the current month. How do I create a filter that will bring me the data from 6 month ago, including my current month, up to today?


Accepted Solutions
Regular Visitor
Posts: 45
Registered: ‎06-25-2015

Re: Filter query by date column

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:

 

IsInPrev.PNG

 

Click OK and you should be good.

 

HTH,

 

Chris

View solution in original post

Regular Visitor
Posts: 45
Registered: ‎06-25-2015

Re: Filter query by date column

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

 

Chris

View solution in original post


All Replies
Frequent Visitor
Posts: 4
Registered: ‎01-05-2018

How to filter a date time column?

I am trying to reduce the amount of rows that Power BI querys from the database, so in the query editor I am adding a filter on a timestamp column from the data source. In the filter options i have choosen "is in the previous", and then selected 6 "months". It appears to calculate first which where the 6 previous months, leaving the current one out, and then it brings the data that belongs to them, but this leaves out all rows from the current month. How do I create a filter that will bring me the data from 6 month ago, including my current month, up to today?

Regular Visitor
Posts: 23
Registered: ‎10-11-2017

Re: How to filter a date time column?

This works for me: 

Solution.jpg

Best regards,
Mattias

Regular Visitor
Posts: 45
Registered: ‎06-25-2015

Re: Filter query by date column

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:

 

IsInPrev.PNG

 

Click OK and you should be good.

 

HTH,

 

Chris

Regular Visitor
Posts: 45
Registered: ‎06-25-2015

Re: Filter query by date column

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

 

Chris

Frequent Visitor
Posts: 4
Registered: ‎01-05-2018

Re: Filter query by date column

That is a nice detail to think about.