Forum Discussion

Sachy123's avatar
Sachy123
Helper V
5 years ago
Solved

Calculate daily returns

I have a data in the following format   Date Price 15-12-20  100 14-12-20         50 13-12-20  20 12-12-20 10   I would like to create a measure that can calculate daily re...
  • amitchandak's avatar
    5 years ago

    Sachy123 , Try new column like

     

    new column =
    var _max = maxx(filter(table, [Date] < earlier([Date])),[Date])
    return
    [Price] - maxx(filter(table, [Date] = _max),[Price])


    or

    new column =
    var _max = maxx(filter(table, [Date] < earlier([Date])),[Date])
    var _1 = maxx(filter(table, [Date] = _max),[Price])
    return
    divide([Price] - _1,_1)