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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
angelosales150
Frequent Visitor

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?

 

1 ACCEPTED SOLUTION
amitchandak
Super User
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

View solution in original post

1 REPLY 1
amitchandak
Super User
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

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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