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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
Anonymous
Not applicable

How to Link Relative Date Slicer with Previous Period Measure

Hiya, 

 

I am making some KPI cards, and am wishing to link the target values to the relative date slicer. (weeks, months, etc)

 

For example, when I choose "Last 2 months", I would like to get a "Previous Month" target. 

When I choose "Last 2 weeks", I would like to get a "Previous Week" target.

 

I could not figure out how to 'extract' that input as some sort of unit to put in a measure. 

 

Help would be much appreciated!

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , Try measure like

 

Last month  =
var _max1 = if(isfiltered('Date'),Min( 'Date'[Date]) , today())
var _max = eomonth(_max1,-1)
var _min = eomonth(_max1,-2)+1
return
CALCULATE([net] ,DATESBETWEEN('Date'[Date],_min,_max))

 

 

Last week =
var _max1 = if(isfiltered('Date'),Min( 'Date'[Date]) , today()) -7
var _max = _max1 - weekday(_max,2)+7
var _min = _max1 - weekday(_max,2)+1
return
CALCULATE([net] ,DATESBETWEEN('Date'[Date],_min,_max))

 

 

 

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

View solution in original post

1 REPLY 1
amitchandak
Super User
Super User

@Anonymous , Try measure like

 

Last month  =
var _max1 = if(isfiltered('Date'),Min( 'Date'[Date]) , today())
var _max = eomonth(_max1,-1)
var _min = eomonth(_max1,-2)+1
return
CALCULATE([net] ,DATESBETWEEN('Date'[Date],_min,_max))

 

 

Last week =
var _max1 = if(isfiltered('Date'),Min( 'Date'[Date]) , today()) -7
var _max = _max1 - weekday(_max,2)+7
var _min = _max1 - weekday(_max,2)+1
return
CALCULATE([net] ,DATESBETWEEN('Date'[Date],_min,_max))

 

 

 

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

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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