cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
PBInath Regular Visitor
Regular Visitor

Relative Date Filter automatically changes from months to days

I have a visual for which I automatically only want to show all days in the current calendar month until yesterday. Yes, this means that on the first day of the month you have an empty visual.

 

I want to do this by setting two relative filters:

- set a relative filter to this month (showing all days in this month);

- set a relative filter to last month (showing all days from a month ago to now).

 

This way, all days after today and days before this calendar month are excluded.


The problems comes here:

My visual is changed accordingly then. However, when I select the visual again and look at the filter settings, both filters have changed to "is in the last 30 days, including today". This is not what I selected! Although the visual is still showing the right information, I wonder what happens if we have a new day. I believe this to be a bug. Below I share a screenshot of how my filters look like after selecting the visual again, which obviously is different than the filters I just set them to a few seconds before. 

 

Anyone knows a solution to this? I rather not do a calculated column showing whether a day is in the current month and belongs to the past days. Power BI offers relative filtering and that should work.

 

relative.pngscreenshot of filters which PBI changes

 

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Relative Date Filter automatically changes from months to days

Hi @PBInath 

Here is a workaround.

Create measures, then add [flag] in the visual level filter

In my example, today=2019/1/25

today = TODAY()

today-year = YEAR([today])

today-month = MONTH([today])

flag =
IF (
    MAX ( 'Table'[year] ) = [today-year]
        && MAX ( 'Table'[month] ) = [today-month]
        && MAX ( 'Table'[Date] ) < [today],
    1,
    0
)

11.png12.png

 

Best Regards

Maggie

 

Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

5 REPLIES 5
PBInath Regular Visitor
Regular Visitor

Re: Relative Date Filter automatically changes from months to days

I see this problems only occurs for me in one report working on a different power BI dataset. 

 

Both reports opened on the same computer using the same Power BI version.  Any idea what might cause the relative date filtering to give problems? All relative date filters I set (no matter what I select: years, months, etc.) change to "last 30 days".

Community Support Team
Community Support Team

Re: Relative Date Filter automatically changes from months to days

Hi @PBInath 

Here is a workaround.

Create measures, then add [flag] in the visual level filter

In my example, today=2019/1/25

today = TODAY()

today-year = YEAR([today])

today-month = MONTH([today])

flag =
IF (
    MAX ( 'Table'[year] ) = [today-year]
        && MAX ( 'Table'[month] ) = [today-month]
        && MAX ( 'Table'[Date] ) < [today],
    1,
    0
)

11.png12.png

 

Best Regards

Maggie

 

Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

PBInath Regular Visitor
Regular Visitor

Re: Relative Date Filter automatically changes from months to days

Somehow this does not work for me. Maybe, I did something wrong. Nevertheless, I created a workaround myself by making an extra calculated column.

 

I was more interested why this standard functionality (using the in built relative date filtering) did not work at first hand.

Community Support Team
Community Support Team

Re: Relative Date Filter automatically changes from months to days

Hi @PBInath 

Very interested how you created a workaround by making an extra calculated column.

 

As tested, if i click on the "Apply filter" after setting the relative slicer, then next time the "Apply filter" should become grey.

If i don't click on it after setting, it shows as your screenshot to be yellow.

 

Best Regards

Maggie

PBInath Regular Visitor
Regular Visitor

Re: Relative Date Filter automatically changes from months to days

It is actually almost similar to yours so I accept it as the solution. I basically created the same thing as you but then as a column, rather than a measure:

 

CurrentMonthFilter = if(and(and(month('date'[date])=month(today());year('date'[date])=year(today()));'date'[date]<TODAY());1;0)
 
Thanks a lot for your help.