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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Use a month slicer to filter some visuals by month and others by past x months

Hi, I have one fact table and one date dimension table. There is a report with one page with many visuals and one slicer to select the month. Some visuals should be filtered to the selected month, others to the past 6 months, others to the past 12 months. How can I handle this without changing the requirement which was provided to me? My solution thus far has been to disconnect the date table and use measures for all values, so that I can provide the filter context inside each measure. Any more elegant solutions would be much appreciated. Thank you.

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

Hi  @Anonymous ,

According to your description, I create this data:

v-yangliu-msft_0-1614127492893.png

Here are the steps you can follow:

1. Create date table.

Date = CALENDARAUTO()

2. Create calculated column.

Month = MONTH('Table'[date])
Month = MONTH('Date'[Date])

3. Create measure.

When slicer selects a date, a visual object displays the selected month:

Flag1 =
var _selectedmonth=SELECTEDVALUE('Date'[Month])
return
IF(
    MAX('Table'[Month])=_selectedmonth,1,0)

Put it in filters and set is = 1

v-yangliu-msft_1-1614127492897.png

When slicer selects date, a visual object displays the first 6 months of selection:

Flag2 =
var _selectedmonth=SELECTEDVALUE('Date'[Month])
return
IF(
    MAX('Table'[Month])=_selectedmonth-6,1,0)

Put it in filters and set is = 1

v-yangliu-msft_2-1614127492899.png

4. Result

v-yangliu-msft_3-1614127492903.png

 

You can downloaded PBIX file from here.

 

Best Regards,

Liu Yang

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

2 REPLIES 2
v-yangliu-msft
Community Support
Community Support

Hi  @Anonymous ,

According to your description, I create this data:

v-yangliu-msft_0-1614127492893.png

Here are the steps you can follow:

1. Create date table.

Date = CALENDARAUTO()

2. Create calculated column.

Month = MONTH('Table'[date])
Month = MONTH('Date'[Date])

3. Create measure.

When slicer selects a date, a visual object displays the selected month:

Flag1 =
var _selectedmonth=SELECTEDVALUE('Date'[Month])
return
IF(
    MAX('Table'[Month])=_selectedmonth,1,0)

Put it in filters and set is = 1

v-yangliu-msft_1-1614127492897.png

When slicer selects date, a visual object displays the first 6 months of selection:

Flag2 =
var _selectedmonth=SELECTEDVALUE('Date'[Month])
return
IF(
    MAX('Table'[Month])=_selectedmonth-6,1,0)

Put it in filters and set is = 1

v-yangliu-msft_2-1614127492899.png

4. Result

v-yangliu-msft_3-1614127492903.png

 

You can downloaded PBIX file from here.

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@Anonymous , if the relative date slicer is not working, then you have to use disconnected tables only.

 

 

Same what is also done here

https://www.youtube.com/watch?v=duMSovyosXE

or

https://community.powerbi.com/t5/Desktop/Required-custom-date-Slicer-Last-7-days-last-15-days-last-30/m-p/1284966#M561629

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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