Forum Discussion
Anonymous
4 years agoNot applicable
Slicer Overlapping Dates
I am trying to create a slicer with the selection options of "Last 12 Months", "Current Year", "Previous Year", and "Previous 2 Years". I have been able to link these slicers properly, but I have to ...
Anonymous
4 years agoNot applicable
Hi Anonymous ,
I created some data:
Here are the steps you can follow:
1. Use Enter data to create a table as a slicer.
2. Create measure.
Current Year =
var _today=TODAY()
return
IF(
MAX('Table'[Date])>=DATE(YEAR(_today),1,1)&&
MAX('Table'[Date])<=TODAY(),1,0)Last 12 Months =
var _today=TODAY()
return
IF(
MAX('Table'[Date])>=DATE(YEAR(_today),MONTH(_today)-12,DAY(_today))&&
MAX('Table'[Date])<=TODAY(),1,0)Previous 2 Year =
var _today=TODAY()
return
IF(
MAX('Table'[Date])>=DATE(YEAR(_today)-2,1,1)&&
MAX('Table'[Date])<=EOMONTH(_today,-12),1,0)Previous Year =
var _today=TODAY()
return
IF(
MAX('Table'[Date])>=DATE(YEAR(_today)-1,1,1)&&
MAX('Table'[Date])<=EOMONTH(_today,-12),1,0)Flag =
SWITCH(
TRUE(),
MAX('Slicer table'[Slicer])="Last 12 Months",[Last 12 Months],
MAX('Slicer table'[Slicer])="Current Year",[Current Year],
MAX('Slicer table'[Slicer])="Previous Year",[Previous Year],
MAX('Slicer table'[Slicer])="Previous 2 Years",[Previous 2 Year])
3. Place [Flag]in Filters, set is=1, apply filter.
4. Result:
If you need pbix, please click 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