Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Same column calculation with condition in another column

Hi,   I have a following table, and would like to calculate the cost difference from previous month per Product. For example, for Product A, the difference between May and June is 1, June and July ...
  • amitchandak's avatar
    4 years ago

    Anonymous , Create a date column

    date = eomonth(date([year], [month], 1),0)

     

     

    then create a new column

    last month Cost =

    var _last = eomonth([Date],-1)

    return

    [cost] - maxx(filter(Table, [Product] = earlier([Product])  && eomonth([Date],0)  = _last) , [Cost])