Forum Discussion

JAKEDBG's avatar
JAKEDBG
New Member
4 years ago
Solved

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.

 

Active = SUMX(EmployeeAsOf,EmployeeAsOf[ActiveRecord])

 

ActiveAsOfPY =
VAR CurrDate = SELECTEDVALUE('Calendar'[CalDate])
VAR Results = CALCULATE(
[Active],
CurrDate >= EmployeeAsOf[DateBeg],
CurrDate <= EmployeeAsOf[DateEnd])
RETURN
RESULTS
 

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

  • 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

    • JAKEDBG's avatar
      JAKEDBG
      New Member

      Thank you for your help!  That was a quick solution and it worked exactly as it needed to be. 

      I appreciate it!