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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Caesarul
Helper II
Helper II

Sync Preset Date Value with a Date between Slicer

Hi, 

 

I've been watching this tutorial on how to make a preset value button panel for certain date ranges

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

 

The Sample File is here: https://github.com/MarkWilcock/lbag-online/tree/master/M%26G%20Results

 

I've succesfully implemented it, but I'm having trouble synchronizing the Preset Value Panel with the Date Slicer. 

 

I want to give my team the chance to get a fast last 3-6-12 months range experience, but I also want to give them the ability to choose a range of 3 months from the past for example. 

The solution I have so far is to place the between date at first date / last date so it doesn't filter anything... but when you choose the last 3-6-12 months in the preset value it doesn't show as well in the slicer, which may be confusing to see. For example: 

 

Caesarul_0-1671007079795.png

 

Any ideas? 

Thank you very much for your support!

 

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

Hi  @Caesarul ,

I created some data:

vyangliumsft_0-1671073220772.png

You can use the Switch() function to determine that the slicer is an option and the date is in a certain interval, so you can display it and add the value.

Here are the steps you can follow:

1. Create measure.

Flag =
var _today=TODAY()
var _1m=DATE(YEAR(_today),MONTH(_today)-1,DAY(_today))
var _3m=DATE(YEAR(_today),MONTH(_today)-3,DAY(_today))
var _6m=DATE(YEAR(_today),MONTH(_today)-6,DAY(_today))
var _1y=DATE(YEAR(_today)-1,MONTH(_today),DAY(_today))
var _ytd=DATE(YEAR(_today),1,1)
var _maxdate=MAXX(ALL('Table'),'Table'[Date])
return
SWITCH(
    TRUE(),
    MAX('Preset'[Preset Code]) = "1M"&&MAX('Table'[Date])>=_1m &&MAX('Table'[Date])<=_today,1,
    MAX('Preset'[Preset Code]) = "3M"&&MAX('Table'[Date])>=_3m &&MAX('Table'[Date])<=_today,1,
    MAX('Preset'[Preset Code]) = "6M"&&MAX('Table'[Date])>=_6m &&MAX('Table'[Date])<=_today,1,
    MAX('Preset'[Preset Code]) = "1Y"&&MAX('Table'[Date])>=_1y &&MAX('Table'[Date])<=_today,1,
    MAX('Preset'[Preset Code]) = "YTD"&&MAX('Table'[Date])>=_ytd &&MAX('Table'[Date])<=_today,1,
    MAX('Preset'[Preset Code]) = "Max"&&MAX('Table'[Date])=_maxdate,1,0)
Value =
SUMX(ALLSELECTED('Table'),[Rand])

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

vyangliumsft_1-1671073220774.png

3. Result:

vyangliumsft_2-1671073220776.png

vyangliumsft_3-1671073220778.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
Caesarul
Helper II
Helper II

hi @v-yangliu-msft 

 

Thank you for investing the time into this. It works perfectly!

 

But my challenge is to sync the Date Between slicer with the Preset Code. 

 

Here's a screenshot of what I mean. The date in table is filtered correctly, but the slicer still remains untouched... 😞 

 

Caesarul_0-1671184964402.png

 

v-yangliu-msft
Community Support
Community Support

Hi  @Caesarul ,

I created some data:

vyangliumsft_0-1671073220772.png

You can use the Switch() function to determine that the slicer is an option and the date is in a certain interval, so you can display it and add the value.

Here are the steps you can follow:

1. Create measure.

Flag =
var _today=TODAY()
var _1m=DATE(YEAR(_today),MONTH(_today)-1,DAY(_today))
var _3m=DATE(YEAR(_today),MONTH(_today)-3,DAY(_today))
var _6m=DATE(YEAR(_today),MONTH(_today)-6,DAY(_today))
var _1y=DATE(YEAR(_today)-1,MONTH(_today),DAY(_today))
var _ytd=DATE(YEAR(_today),1,1)
var _maxdate=MAXX(ALL('Table'),'Table'[Date])
return
SWITCH(
    TRUE(),
    MAX('Preset'[Preset Code]) = "1M"&&MAX('Table'[Date])>=_1m &&MAX('Table'[Date])<=_today,1,
    MAX('Preset'[Preset Code]) = "3M"&&MAX('Table'[Date])>=_3m &&MAX('Table'[Date])<=_today,1,
    MAX('Preset'[Preset Code]) = "6M"&&MAX('Table'[Date])>=_6m &&MAX('Table'[Date])<=_today,1,
    MAX('Preset'[Preset Code]) = "1Y"&&MAX('Table'[Date])>=_1y &&MAX('Table'[Date])<=_today,1,
    MAX('Preset'[Preset Code]) = "YTD"&&MAX('Table'[Date])>=_ytd &&MAX('Table'[Date])<=_today,1,
    MAX('Preset'[Preset Code]) = "Max"&&MAX('Table'[Date])=_maxdate,1,0)
Value =
SUMX(ALLSELECTED('Table'),[Rand])

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

vyangliumsft_1-1671073220774.png

3. Result:

vyangliumsft_2-1671073220776.png

vyangliumsft_3-1671073220778.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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

Top Solution Authors