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

Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers. Get Fabric certified for FREE! Learn more

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))

 

 

 

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))

 

 

 

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
PBIApril_Carousel

Power BI Monthly Update - April 2025

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

Notebook Gallery Carousel1

NEW! Community Notebooks Gallery

Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.

April2025 Carousel

Fabric Community Update - April 2025

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