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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
wo_guy
Frequent Visitor

How to create date filter buttons?

I want date buttons as filters to my dataset.

 

e.g. YTD (relative to the Max date in the dataset), 6 Months and 3 Months

 

Date ButtonsDate Buttons

I am following the example given here but I am unable to get it to work or unable to replicate the example.

 

I even created the measure for YTD:

 

 

 

 

YTD Filter = 
VAR DateDiff_=
    DATEDIFF(MAX('Cycle Reports'[DATE]), MIN('Cycle Reports'[DATE]), DAY)
RETURN
    IF(DateDiff_ <= 365,1)

 

 

 

 

But I am unable to add it to the filters pane for it to work.

 

How can I create this functionality?

 

Please find the OneDrive pbix file link for reference

 

Thank you.

2 REPLIES 2
wo_guy
Frequent Visitor

Hi @amitchandak Thank you,
I followed your example.

Please find the file so far here (OneDrive Link)

However, I am unable to get the values as filters.

Please advise how can I build it further to get the functionality as desired.

amitchandak
Super User
Super User

@wo_guy m Try a measure like

 

Switch Period =
var _max1 = if(isfiltered('Date'),MAX( 'Date'[Date]) , today())

var _max = if(SELECTEDVALUE(Period[PeriodType],"MTD") = "Yesterday",MAX( 'Date'[Date])-1 , today()-1)
var _min =
SWITCH(SELECTEDVALUE(Period[PeriodType],"MTD"),
"YTD",eomonth(_max,-1*MONTH(_max))+1 , //FY April -March
"FYTD",if( Month(_max) <4 , date(year(_max)-1,4,1) ,date(year(_max),4,1)), //FY April -March
"QTD",eomonth(_max,-1* if( mod(Month(_max),3) =0,3,Month(_max)))+1,
"MTD",eomonth(_max,-1)+1 ,
"WTD", _max -WEEKDAY(_max,2)+1,
"today", today() ,
"Yesterday", today()-1 ,
"Cumm", Minx(ALLSELECTED('Date'),'Date'[Date]),
"Rolling 3", date(Year(_max), month(_max) -3, Day(_max))+1,
"Rolling 6", date(Year(_max), month(_max) -6, Day(_max))+1,
"Rolling 12", date(Year(_max), month(_max) -12, Day(_max))+1,
BLANK())
return
CALCULATE([net] ,DATESBETWEEN('Date'[Date],_min,_max))

 

refer

https://medium.com/chandakamit/power-bi-when-i-felt-lazy-and-i-needed-too-many-measures-ed8de20d9f79

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.