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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Create custom date slicer based current selected periosd

Hi all,

I wish to create a model with two date slicers (current and previous). Ideally, I want when I select on a date slicer between e.g 1/05/2022 to 31/05/2022 the previous date should dynamically move one month before. In other pages, I would like the previous date to be within the same period selected. For example, if i select 2 months on current date slicer, pevious should be automatically show 2 months before the end date of the current. 

I have all the measures such as previous two months sales but all i need is to show the dynamic interactivity between previous and current date slicers. I've tried edit interactions but it seems not to work for my scenario. I'm using two date sliders with between.

Please help 

1 REPLY 1
amitchandak
Super User
Super User

@Anonymous , try one of three options

 

//previous period month
Same Date range last period =
var _diff = datediff(MIN('Date'[date]),max('Date'[date]),Month)+1
var _p_st_date = MINX('Date',DATEADD('Date'[date],-1*_diff,Month))-1
var _p_end_date = MAXX('Date',DATEADD('Date'[date],-1*_diff,Month))-1
Return
CALCULATE(sum(Sales[Sales Amount]),all('Date'[date]),'Date'[date]>=_p_st_date && 'Date'[date]<= _p_end_date
)


Same Date range last period Month =
var _diff = datediff(MIN('Date'[date]),max('Date'[date]),Month)+1
Return
CALCULATE(sum(Sales[Sales Amount]),dateadd('Date'[date],-1*_diff,Month))

 

 

Same Date range last period =
var _diff = datediff(MIN('Date'[date]),max('Date'[date]),Month)+1
var _p_st_date = Eomonth(MINX('Date','Date'[date], _1* _diff)-1
var _p_end_date = Eomonth(MAXX('Date','Date'[date], _1* _diff)
Return
CALCULATE(sum(Sales[Sales Amount]),all('Date'[date]),'Date'[date]>=_p_st_date && 'Date'[date]<= _p_end_date
)

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

Power BI Monthly Update - November 2025

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

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!

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.