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

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

Reply
Anonymous
Not applicable

Custom date range in Line chart from slicer selection

Hi All,

 

I would like some help on this one as I cannot figure it out.

 

I have a regular date range slicer for Date. 

 

I want to show the last 3 month from the max selected date in the slicer (not current date). I want to show the results in a line chart

 

Ex. Selected Slicer Value: 2020-07-01, the range in line chart shows 2020-05-02 to 2020-07-01

 

I have the following calculation but the line chart is still showing for the full date range:

 

 

Sales Last 60 d = 
var Ldate = MAX('Date'[Date]) //Last date
var Fdate = (Ldate-60) // last 60 days
return
calculate([Sales Total], 
    FILTER (
        Sales,
        RELATED('Date'[Date]) >= Fdate )))
 

 

Thanks!

 

1 ACCEPTED SOLUTION
v-zhenbw-msft
Community Support
Community Support

Hi @Anonymous ,

 

We can create a date table and a measure to meet your requirement.

The date table has no relationship with sales table.

 

1. Create a date table to be a slicer.

 

Date = CALENDAR("2020/1/1","2020/8/1")

 

cus1.jpg

 

cus2.jpg

 

2. Then we can create a measure.

 

Sales Last 60 d = 
var _SelectDate = SELECTEDVALUE('Date'[Date])
var _Fdate = _SelectDate-60
var _result = 
calculate(
    SUM('Sales table'[Sales]), 
    FILTER (
        'Sales table',
        'Sales table'[Date]<=_SelectDate && 'Sales table'[Date] >=_Fdate))
return
IF(
    ISBLANK(_SelectDate),SUM('Sales table'[Sales]),_result)

 

cus3.jpg

 

cus4.jpg

 

If it doesn’t meet your requirement, could you please show the exact expected result based on the table that we have shared?

BTW, pbix as attached.

 

Best regards,

 

Community Support Team _ zhenbw

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

View solution in original post

4 REPLIES 4
v-zhenbw-msft
Community Support
Community Support

Hi @Anonymous ,

 

How about the result after you follow the suggestions mentioned in my original post?

Could you please provide more details or expected result about it If it doesn't meet your requirement?

If you've fixed the issue on your own please kindly share your solution.

 

Best regards,

 

Community Support Team _ zhenbw

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

v-zhenbw-msft
Community Support
Community Support

Hi @Anonymous ,

 

We can create a date table and a measure to meet your requirement.

The date table has no relationship with sales table.

 

1. Create a date table to be a slicer.

 

Date = CALENDAR("2020/1/1","2020/8/1")

 

cus1.jpg

 

cus2.jpg

 

2. Then we can create a measure.

 

Sales Last 60 d = 
var _SelectDate = SELECTEDVALUE('Date'[Date])
var _Fdate = _SelectDate-60
var _result = 
calculate(
    SUM('Sales table'[Sales]), 
    FILTER (
        'Sales table',
        'Sales table'[Date]<=_SelectDate && 'Sales table'[Date] >=_Fdate))
return
IF(
    ISBLANK(_SelectDate),SUM('Sales table'[Sales]),_result)

 

cus3.jpg

 

cus4.jpg

 

If it doesn’t meet your requirement, could you please show the exact expected result based on the table that we have shared?

BTW, pbix as attached.

 

Best regards,

 

Community Support Team _ zhenbw

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

Greg_Deckler
Community Champion
Community Champion

@Anonymous - My Complex Selector quick measure provides an example of this scenario almost exactly.

 

https://community.powerbi.com/t5/Quick-Measures-Gallery/The-Complex-Selector/td-p/1116633

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Can I download the sample to try it out myself?

 

I dont understand why something like this is not available out of the box?

 

Appreciate further help in this.

 

Thanks

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 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.

Top Solution Authors