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
PeterVachon
Frequent Visitor

Struggling to build my measure (Rolling 12 months of 2021 vs Rolling 12 month 2020)

Here's what I tought of doing to get the rolling 12 months sales from 2020 (sale 12 months period of last year) 
I want it so i can use my relative date slicer

 

This keep returning me the same sales of the current year and not the 12 months before.... 
I know it's just a problem of my date because if i change the VAR i created for a date (like : 

DATEVALUE("2020-06-11"))   it's working perfectly fine... but i want it dynamic... 



here's the code 

 

 

LYT12M Sales test =
Var SelectedMaxDate =
CALCULATE (
MAX ( 'Calendar'[Date] ),
FILTER( 'Calendar',
DATEADD ('Calendar'[Date], -12, MONTH )
)
)


Var MinDate =
CALCULATE (
MIN ( 'Calendar'[Date] ),
FILTER ( 'Calendar',
DATEADD ( 'Calendar'[Date], -12, MONTH ) > SelectedMaxDate
)
)

Return
CALCULATE (
[NET for RETURN] ,    --(which is just a quick measure with a filter on)
( 'Calendar' ),
'Calendar'[Date] < SelectedMaxDate,
'Calendar'[Date] >= MinDate
)
4 REPLIES 4
v-xulin-mstf
Community Support
Community Support

Hi @PeterVachon,

 

Is your issue solved?

If you still have some question, please don't hesitate to let me known.‌‌

 

Best Regards,

Link

 

Is that the answer you're looking for? If this post helps, then please consider Accept it as the solution. Really appreciate!

PeterVachon
Frequent Visitor

My Other test seems  give me this error (i did some test with a card in my dashboard  i am able to get the proper dates now (the all filter is skipping my selection in my slicer which is causing problem) .  but when i try this version i get this 

 

PeterVachon_0-1623428513846.png

 

 

LYT12M SalesBefore R&W test =
Var SelectedMaxDate =
CALCULATE (
MAX ( 'Calendar'[Date] ),
DATEADD ('Calendar'[Date], -12, MONTH )
)


Var MinDate =
CALCULATE (
MIN ( 'Calendar'[Date] ),
DATEADD ('Calendar'[Date], -12, MONTH )
)

Return

CALCULATE (
[NET for RETURN] ,
'Calendar'[Date]< SelectedMaxDate,
'Calendar'[Date] >= MinDate
)

Hi @PeterVachon

 

Could you provide sample data and expected output after removing sensitive data?
Sample data and expected output would help tremendously.

 

Best Regards,

Link

 

Is that the answer you're looking for? If this post helps, then please consider Accept it as the solution. Really appreciate!

I won't provide no sorry. 

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.