Forum Discussion
Anonymous
5 years agoNot applicable
R12 Calculation Error
Hello everyone, I am trying to calculate R12 for past 5 years. I am filtering my data based on Date lookup table. The max or latest date is 01/07/2021(dd/mm/yyyy). When I choose this latest date(July...
- 5 years ago
Hey Anonymous ,
I'm not really sure if the approach makes sense as DATEADD just changes the dates in the column. I think what you are looking for is the function DATESINPERIOD. Try the following approach:
R12 IND = VAR SelectedMaxDate = MAX( 'Date Lookup'[Date] ) VAR MinDate = CALCULATE( MIN( 'Date Lookup'[Date] ), DATESINPERIOD( 'Date Lookup'[Date], SelectedMaxDate, -1, YEAR ) ) RETURN MinDateIf you need any help please let me know.If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍Best regardsDenisBlog: WhatTheFact.biFollow me: twitter.com/DenSelimovic
selimovd
Most Valuable Professional
5 years agoHey Anonymous ,
I'm not really sure if the approach makes sense as DATEADD just changes the dates in the column. I think what you are looking for is the function DATESINPERIOD. Try the following approach:
R12 IND =
VAR SelectedMaxDate = MAX( 'Date Lookup'[Date] )
VAR MinDate =
CALCULATE(
MIN( 'Date Lookup'[Date] ),
DATESINPERIOD(
'Date Lookup'[Date],
SelectedMaxDate,
-1,
YEAR
)
)
RETURN
MinDate
If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
Best regards
Denis
Blog: WhatTheFact.bi
Follow me: twitter.com/DenSelimovic
- Anonymous5 years agoNot applicable
Hello Denis, thanks a lot for your solution! It worked 😊