Forum Discussion

LLT1021's avatar
LLT1021
Helper I
3 years ago
Solved

Finding previous value with measure

Hi all! I have a question regarding previous values.  I have a table with data about employees of a company like; Name     Gender   Exit date          Date                Number of people leavin...
  • v-zhangti's avatar
    v-zhangti
    3 years ago

    Hi, LLT1021 

     

    You can try the following methods.

    Previous date = 
    Var _leavedate=CALCULATE(MAX('Fact Employee'[Date]),FILTER(ALL('Fact Employee'),[People leaving]=1&&[Name]=SELECTEDVALUE('Fact Employee'[Name])))
    Var _previousdate=CALCULATE(MAX('Fact Employee'[Date]),FILTER(ALL('Fact Employee'),[Name]=SELECTEDVALUE('Fact Employee'[Name])&&[Date]<_leavedate))
    Return
    IF(SELECTEDVALUE('Fact Employee'[People leaving])=1,_previousdate,BLANK())
    Result = CALCULATE(MAX('Fact Financial'[Distance]),FILTER(ALL('Fact Financial'),[Name]=SELECTEDVALUE('Fact Employee'[Name])&&[Date]=[Previous date]))

    Is this the result you expect?

     

    Best Regards,

    Community Support Team _Charlotte

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.