Forum Discussion

FZOU's avatar
FZOU
Helper IV
5 years ago
Solved

Substract two rows

Hello,

 

i have this table with this formula to show result column,it's worked but i need to no calculate the result with red rectangle.

 

i didn't find how to make him jump and not substract bike by car and car by bus,the needed result is shown below

 

Any one can help please ? thank you 🙂

  • FZOU , Create a new column like

    New column =
    var _ min = MINX(filter(Table, [Index] > earlier([Index] ) , [Category] = earlier([Category])),[Index])
    return
    [value] -MINX(filter(Table, [Index] =_min , [Category] = earlier([Category])),[value])

4 Replies

  • tex628's avatar
    tex628
    Community Champion

    Try this:

     

     

    Result =
    VAR Category_ = Table3[Category]
    VAR Index_1 = Table3[Index]
    VAR Index_2 = CALCULATE( MIN(Table3[Index]) , Table3[Index] > Index_1 , Table3[Category] = Category_)
    Return
    Table3[Value] - CALCULATE(Table3[Value] , Table3[Index] = Index_2 )

     

     


    Br,
    J

    • FZOU's avatar
      FZOU
      Helper IV

      Hi tex628 

        thank you for your response, but i tried your formula and nothing happend it show the same values as the column value

  • FZOU , Create a new column like

    New column =
    var _ min = MINX(filter(Table, [Index] > earlier([Index] ) , [Category] = earlier([Category])),[Index])
    return
    [value] -MINX(filter(Table, [Index] =_min , [Category] = earlier([Category])),[value])

    • FZOU's avatar
      FZOU
      Helper IV

      amitchandak  thank you very much it works, otherwise there is a solution to replace the values (4,8,2) with "-" or blank ? thank you