Forum Discussion
Measure with Prior Year
I have two measures that are working great as defined below. I am also trying to create a new measure that returns Prior Year Actives. The fact table and calendar table is not joined as the fact table has two date range fields, DateBeg and DateEnd.
Tried to use DateAdd function to create a new measure but that is not valid.
VAR PYCurrDate = DATEADD(SELECTEDVALUE('Calendar'[CalDate]), -1, YEAR)
Appreciate any help on how I can achieve this and thank you!
JAKEDBG , Try Like
ActiveAsOfPY =
VAR CurrDate1 = SELECTEDVALUE('Calendar'[CalDate])
VAR CurrDate = date(year(CurrDate1)-1, month(CurrDate1), day(CurrDate1))
VAR Results = CALCULATE(
[Active],
CurrDate >= EmployeeAsOf[DateBeg],
CurrDate <= EmployeeAsOf[DateEnd])
RETURN
RESULTS
2 Replies
- amitchandak
Super User
JAKEDBG , Try Like
ActiveAsOfPY =
VAR CurrDate1 = SELECTEDVALUE('Calendar'[CalDate])
VAR CurrDate = date(year(CurrDate1)-1, month(CurrDate1), day(CurrDate1))
VAR Results = CALCULATE(
[Active],
CurrDate >= EmployeeAsOf[DateBeg],
CurrDate <= EmployeeAsOf[DateEnd])
RETURN
RESULTS- JAKEDBGNew Member
Thank you for your help! That was a quick solution and it worked exactly as it needed to be.
I appreciate it!