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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Dynamic date range selection

Hi All,

 

Example:- If the user chooses the date range slicer 03/1/2022 - 04/01/2022, make the table show the same date range for the prior 3 years, how should I make it.

 

Need your help!

 

Thanks,

Francis

5 REPLIES 5
v-henryk-mstf
Community Support
Community Support

Hi @Anonymous ,

 

Whether the advice given by @Jihwan_Kim  has solved your confusion, if the problem has been solved you can mark the reply for the standard answer to help the other members find it more quickly. If not, please point it out.


Looking forward to your feedback.


Best Regards,
Henry

Jihwan_Kim
Super User
Super User

Hi,

I am not sure whether I understood your question correctly, but please check the below picture and the attached pbix file. I do not know how your data model looks like, but I tried to create a sample pbix file like below, and I hope the below can give some ideas on how to apply a similar calculated measrue to your data model.

 

Picture1.png

 

Quantity desired outcome: = 
VAR _prioroneyearrange =
    DATEADD ( 'Calendar'[Date], -1, YEAR )
VAR _priortwoyearrange =
    DATEADD ( 'Calendar'[Date], -2, YEAR )
VAR _priorthreeyearrange =
    DATEADD ( 'Calendar'[Date], -3, YEAR )
VAR result =
    CALCULATE (
        SUM ( Data[Quantity] ),
        KEEPFILTERS ( FILTER ( ALL ( Data ), Data[Date] IN _prioroneyearrange ) )
    )
        + CALCULATE (
            SUM ( Data[Quantity] ),
            KEEPFILTERS ( FILTER ( ALL ( Data ), Data[Date] IN _priortwoyearrange ) )
        )
        + CALCULATE (
            SUM ( Data[Quantity] ),
            KEEPFILTERS ( FILTER ( ALL ( Data ), Data[Date] IN _priorthreeyearrange ) )
        )
RETURN
    result

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.
Anonymous
Not applicable

Still I'm not getting the desired output , Thank you

Anonymous
Not applicable

Hi Amit,

 

This scenario wouldn't helped me out 

 

-Francis

amitchandak
Super User
Super User

@Anonymous , You can not default range slicer. You can use relative date slicer or a work around default column like

 

Year Type = Switch( True(),
year([Date])<= year(Today()) && year([Date])>= year(Today())-3,"Last 3 Years" ,
Format([Date],"YYYY")
)

 

 

Default Date Today/ This Month / This Year: https://www.youtube.com/watch?v=hfn05preQYA

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
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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
Users online (6,470)