Forum Discussion
Filter date in a Slicer Button
Hello Community!
I'm trying to make some button filters to filter the date from a table.
Ultimo Semestre(Last Semester: filter the last 6 months) and
Ultimo Ano(Last Year: filter the last 12 months).
These buttons are on the left side of the dashboard.
I wrote a measure to both buttons filter and I was just trying random dates and it isn't working.
The measure gets the Dates from 'meta12022[Data]'.
What I did wrong here?
angelosales150 , You need have two measures two be switch based on independent table slicer having that value
//Date1 is independent Date table
6 Month =
var _max =if(isfiltered('Date'), maxx(allselected(Date),Date[Date]), today())
var _min = eomonth(_min, -6)
return
calculate( sum(Table[Value]), filter('Table', 'Table'[Date] >=_min && 'Table'[Date] <=_max))//Date1 is independent Date table
12 Month =
var _max =if(isfiltered('Date'), maxx(allselected(Date),Date[Date]), today())
var _min = eomonth(_min, -12)
return
calculate( sum(Table[Value]), filter('Table', 'Table'[Date] >=_min && 'Table'[Date] <=_max))Slicer need to created like this
https://medium.com/chandakamit/power-bi-when-i-felt-lazy-and-i-needed-too-many-measures-ed8de20d9f79
1 Reply
- amitchandak
Super User
angelosales150 , You need have two measures two be switch based on independent table slicer having that value
//Date1 is independent Date table
6 Month =
var _max =if(isfiltered('Date'), maxx(allselected(Date),Date[Date]), today())
var _min = eomonth(_min, -6)
return
calculate( sum(Table[Value]), filter('Table', 'Table'[Date] >=_min && 'Table'[Date] <=_max))//Date1 is independent Date table
12 Month =
var _max =if(isfiltered('Date'), maxx(allselected(Date),Date[Date]), today())
var _min = eomonth(_min, -12)
return
calculate( sum(Table[Value]), filter('Table', 'Table'[Date] >=_min && 'Table'[Date] <=_max))Slicer need to created like this
https://medium.com/chandakamit/power-bi-when-i-felt-lazy-and-i-needed-too-many-measures-ed8de20d9f79