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
Puja
Helper III
Helper III

Date slicer help

Hello all,

I need some help creating a custom date slicer. When the user selects a year, I want the visual to show data from the same year, the previous six months, and the coming six months.  If I choose 2010 on this slicer, the time frame will last six months, from 2009 through the first six months of 2011. 

 

TIA

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

Hi  @Puja ,

I created some data:

vyangliumsft_0-1669944106299.png

Here are the steps you can follow:

1. Create calculated table.

Table 2 =
DISTINCT('Table'[Year])

vyangliumsft_1-1669944106301.png

2. Create measure.

Flag =
var _select=SELECTEDVALUE('Table 2'[Year])
var _previoussixmonths=EOMONTH(DATE(_select,1,1),-8) //2009 5 .31
var _comingsixmonths=EOMONTH(DATE(_select,12,31),+6)
return
IF(
    MAX('Table'[Date]) >_previoussixmonths &&MAX('Table'[Date])<=_comingsixmonths,1,0)

3. Place [Flag]in Filters, set is=1, apply filter.

vyangliumsft_2-1669944106302.png

4. Result:

vyangliumsft_3-1669944106305.png

 

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
Puja
Helper III
Helper III

hi @v-yangliu-msft 

Excellent.

Thank you somuch 🙂

v-yangliu-msft
Community Support
Community Support

Hi  @Puja ,

I created some data:

vyangliumsft_0-1669944106299.png

Here are the steps you can follow:

1. Create calculated table.

Table 2 =
DISTINCT('Table'[Year])

vyangliumsft_1-1669944106301.png

2. Create measure.

Flag =
var _select=SELECTEDVALUE('Table 2'[Year])
var _previoussixmonths=EOMONTH(DATE(_select,1,1),-8) //2009 5 .31
var _comingsixmonths=EOMONTH(DATE(_select,12,31),+6)
return
IF(
    MAX('Table'[Date]) >_previoussixmonths &&MAX('Table'[Date])<=_comingsixmonths,1,0)

3. Place [Flag]in Filters, set is=1, apply filter.

vyangliumsft_2-1669944106302.png

4. Result:

vyangliumsft_3-1669944106305.png

 

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

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.

Top Solution Authors