Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Anonymous
Not applicable

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.

 

screenshot of filters which PBI changesscreenshot of filters which PBI changes

 

1 ACCEPTED SOLUTION
v-juanli-msft
Community Support
Community Support

Hi @Anonymous 

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.

View solution in original post

5 REPLIES 5
v-juanli-msft
Community Support
Community Support

Hi @Anonymous 

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.

Anonymous
Not applicable

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.

Hi @Anonymous 

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

Anonymous
Not applicable

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

Anonymous
Not applicable

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.
 
 

 

 

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.