Forum Discussion

ashrafkotb's avatar
ashrafkotb
Icon for Helper I rankHelper I
6 years ago
Solved

How to create a calculated column to subtract previous row value?

Hello, I need to create a calculated column that subtracts the current row value from the previous row value based on date and customer name. For example:   Date Value Customer Calc_column (...
  • az38's avatar
    6 years ago

    Hi ashrafkotb 

    try

    Calc_column = 
    var _thisDate = Table[Date]
    var _prevDate = CALCULATE(MAX(Table[Date]), ALLEXCEPT(Table, Table[Customer]), Table[Date] < _thisDate )
    
    RETURN
    Table[Value] - CALCULATE(MAX(Table[Value]), ALLEXCEPT(Table, Table[Customer]), Table[Date] = _prevDate )