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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
jlf81
Frequent Visitor

Current vs Previous based on relative filter

Is there anyway to build a measure that would give you the current period vs the previous period, based on a relative filter. 

 

For eaxmple if the filter is set to last 30 days it would show the last 30 days minus days 31-60, a separate measure that just shows days 31-60

 

Then if you changed the relative filter to last 60, it would show it minus days 61-120, a separate measure that just shows days 61-120

 

If it's not possible with just 2 measures is there a neat way so I can have a number of different similar measures and use bookmarks to change the view of it?

 

4 REPLIES 4
v-shex-msft
Community Support
Community Support

Hi @jlf81,

Any update on your scenario? You only shared less information so that we not clarify your structure and do the test with them.

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
jlf81
Frequent Visitor

@amitchandak Awesome, thank you.

 

Is there any way to edit that to deal with YTD\MTD? or would I need to adjust that measure

 

Little typo in you solution 'var _min =maxx(date,date[date])' should be 'var _min =minx(date,date[date])' shouldn't it? Also couldn't get that last bit to work, but replaced it with ,DATESBETWEEN('Dim Date'[Date],_minX,_maxX))) and that seems ok

Hi @jlf81,

Can you please share some dummy data with a similar data structure and expected results? It should help us clarify your scenario and test to coding formula.

How to Get Your Question Answered Quickly  

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
amitchandak
Super User
Super User

@jlf81 , Try a measure like

 

Last Period =
var _max =maxx(date,date[date])
var _min =maxx(date,date[date])
var datediff1 = datediff(_min,_max,day)
var _maxX = _max-datediff1
var _minX = _min -datediff1
return
CALCULATE(SUM(Sales[Sales Amount]),filter(all(date,date[date]<=_maxX &&date[date]>=_minX)))

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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