Search code examples
excelgoogle-sheetsexcel-formulaspreadsheetlookup

How to make arithmetic operations depending on some conditions in google spreadsheet/excel


I am new to google spreadsheet/excel and I need a job to be done. Please help me to solve this

Dropdown Price Available amount
User 1 25 350
User 2 30 500
User 1 50 ???
User 2 75 ???

What I want is when a user selects a user from the dropdown(first column) and fills in the price column, the 3rd column needs to auto-update with the value of the previous same user, available amount - Price of current row value.

i.e. in the given example, the 3rd row's last column value is filled with value 300 (350-50), and the 4th row's last column value is filled with value 425 (500-75). I have given the spreadsheet link for reference.

Ref: Spreadsheet example


Solution

  • Use this formula

    =IF(A4="",,INDEX(FILTER(C$2:C3, A$2:A3=A4), 
                     COUNTA(FILTER(C$2:C3, A$2:A3=A4)), 1)-B4)
    

    enter image description here