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
sonya7
Helper III
Helper III

last 6 months by date

I have line charts that I want to show the last 6 months based on the date filter. how can I do that?

 

 

3 REPLIES 3
v-zhangti
Community Support
Community Support

Hi, @sonya7 

 

You can try the following methods.
Sample data:

vzhangti_0-1662711041119.png

Create a new date table as a slicer.
Date table:

Date = CALENDAR(MIN('Table'[Date]),MAX('Table'[Date]))
Measure = 
Var Maxdate=SELECTEDVALUE('Date'[Date])
Var Mindate=eomonth(Maxdate, -6)
return
IF(SELECTEDVALUE('Table'[Date])>=Mindate&&SELECTEDVALUE('Table'[Date])<=Maxdate,1,0)

Put the measure in the line chart and set equal to 1.

vzhangti_1-1662711223108.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

it worked but why is it showing more than 6 months months? a metric is required to give the last 6 months of that year

amitchandak
Super User
Super User

@sonya7 , If you want select a date and then want to show 6 month data, the slicer needs to be on an independent date table 

 

example

//Date1 is independent Date table, Date is joined with Table
new measure =
var _max = maxx(allselected(Date1),Date1[Date])
var _min = eomonth(_max, -6) +1
return
calculate( sum(Table[Value]), filter('Date', 'Date'[Date] >=_min && 'Date'[Date] <=_max))

 

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
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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