Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Calculate difference between two values per ID

Hello everyone I currently have this type of data set and was wondering if there is a way to calculate the difference month over month, with January being the first month, per employee.  Employee...
  • Greg_Deckler's avatar
    Greg_Deckler
    3 years ago

    Anonymous Whoops, was troubleshooting. Yes, that can be done:

    Column = 
        VAR __Employee = [Employee ID]
        VAR __Date = [Date]
        VAR __Amount = [Amount]
        VAR __PrevDate = MAXX(FILTER(ALL('Table'),[Date]<__Date),[Date])
        VAR __PrevAmount = MAXX(FILTER(ALL('Table'),[Employee ID] = __Employee && [Date] = __PrevDate),[Amount])
        VAR __Diff = __Amount - __PrevAmount
        VAR __Result = IF(__PrevAmount = BLANK(), BLANK(), __Diff)
    RETURN
        __Result