Google-sheets – Text conditionals in Google Spreadsheets

formulasgoogle sheets

I want to write a formula where I can add values to a cell whether another cell states approves the "transaction".

It will be easier to explain with an example. Consider a spreadsheet containing the costs of a flat share.

Purchase    Adam Joe Peter To
 x           $5  $5   $0   Peter
 y           $0  $7   $7   Adam

Given the table above, I would like to create another table showing how much money do people owe each other:

      Owe to
      Adam  Joe  Peter
Adam   $0    $0   $5
Joe    $7    $0   $5
Peter  $7    $0   $0

I am not sure how to create the second table. Any ideas how? I was thinking of something along the lines of a loop, and if statements.

Best Answer

If you're thinking about "loop and if statements", you should look into Google Apps Scripts.

Other than that, it seems you're looking for the TRANSPOSE function, in conjunction with the FILTER function. Take a look at the Google Spreadsheets Function List.

If you can tell me the purpose of the Purchase column in your example, I might be able to set up a working example.