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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

My dates of the line chart are not filtering according to the tree map filter.

HI,
I'm totally new to power BI.
I'm trying to filter date range of the line chart using a tree map filter as "In the last 1 month, 2 months, 3 months, 6 months, 1 year, and 2 years". That is if I click on 1 month the line grapgh should show last 1 month data from today.

IndrachapaLA_0-1662695415987.png

but It does not change when clicking 1month. Can you all please help.

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , In this case, your date range needs to be bigger than the selected period else you need independent date slicer

 

var _max = if(SELECTEDVALUE(Period[PeriodType],"MTD") = "Yesterday",MAX( 'Date'[Date])-1 , today()-1)
var _min =
SWITCH(SELECTEDVALUE(Period[PeriodType],"MTD"), //selected by tree map
"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 ,
"2 Month", date(Year(_max), month(_max) -3, Day(_max))+1,
"3 Month", date(Year(_max), month(_max) -3, Day(_max))+1,
"6 Month", date(Year(_max), month(_max) -6, Day(_max))+1,
"12 Month", date(Year(_max), month(_max) -12, Day(_max))+1,
BLANK())
return
CALCULATE([Net], FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))

 

 

In case you select a range small then what you want

Need of an Independent Date Table:https://www.youtube.com/watch?v=44fGGmg9fHI

 

 

 

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

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @Anonymous,

Did the above suggestions help with your scenario? if that is the case, you can consider Kudo or Accept the helpful suggestions to help others who faced similar requirements.

If these also don't help, please share more detailed information to help us clarify your scenario to test.

How to Get Your Question Answered Quickly 

Regards,

Xiaoxin Sheng

amitchandak
Super User
Super User

@Anonymous , In this case, your date range needs to be bigger than the selected period else you need independent date slicer

 

var _max = if(SELECTEDVALUE(Period[PeriodType],"MTD") = "Yesterday",MAX( 'Date'[Date])-1 , today()-1)
var _min =
SWITCH(SELECTEDVALUE(Period[PeriodType],"MTD"), //selected by tree map
"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 ,
"2 Month", date(Year(_max), month(_max) -3, Day(_max))+1,
"3 Month", date(Year(_max), month(_max) -3, Day(_max))+1,
"6 Month", date(Year(_max), month(_max) -6, Day(_max))+1,
"12 Month", date(Year(_max), month(_max) -12, Day(_max))+1,
BLANK())
return
CALCULATE([Net], FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))

 

 

In case you select a range small then what you want

Need of an Independent Date Table:https://www.youtube.com/watch?v=44fGGmg9fHI

 

 

 

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
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.