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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Zabeer
Helper I
Helper I

Creating dynamic date periods based on a selected value in slicer

Hello PowerBI Community.

I would like to create 3 dynamic date periods (dates in the last 12 months, dates between last 12 and 24 months, dates between last 24 and 36 months) based on the date selected in a slicer of the same date table.


Capture.PNG

So when i select 18/07/2017, i would like to have all dates between 18/07/2016 to 18/07/2017 (last 12 months) in a new table. Similarly, for dates between 18/07/2015 to 18/07/2016 and 18/07/2014 to 18/07/2015.

I tried using DATESINPERIOD to achieve the above result. However, I was unable to provide the selected value from the slicer to <startdate>

Kindly help. Thank you


 

4 REPLIES 4
v-lili6-msft
Community Support
Community Support

hi, @Zabeer 

You could use DATESINPERIOD or DATESBETWEEN Funtion to create the measure like below:

For example:

dates in the last 3 days, dates between last 3 and 6 days, dates between last 6 and 12 days

last 3 days = CALCULATE(SUM('Table'[Value]),DATESINPERIOD('Date'[Date],MAX('Date'[Date]),-3,DAY))
last 3 and 6 days = CALCULATE(SUM('Table'[Value]),DATESINPERIOD('Date'[Date],MAX('Date'[Date])-3,-3,DAY))
last 6 and 12 days = CALCULATE(SUM('Table'[Value]),DATESINPERIOD('Date'[Date],MAX('Date'[Date])-6,-6,DAY))

You could adjust it to your requirements.

and here is my simple sample pbix file, please try it.

 

If not your case, please share your simple sample pbix file and expected output.

 

Best Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
VijayP
Super User
Super User

Table For Dates = CALENDAR(SELECTEDVALUE(DateTable[Date]),MAX(DateTable[Date]))

Please try this and let me know whether you are able fulfill your requirement




Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
MY Blog || My YouTube Channel || Connect with me on Linkedin || My Latest Data Story - Ageing Analysis

Proud to be a Super User!


Unfortunately, this doesn't work. 
This is the error message :
"The start date or end date in Calendar Function can not be a blank value"

Create the Slicer of Dates and Select any specific Date to Create the Filter Context with SELECTEDVALUE Function




Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
MY Blog || My YouTube Channel || Connect with me on Linkedin || My Latest Data Story - Ageing Analysis

Proud to be a Super User!


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.