How to subtract Debit value from previous column Balance value

I want to create a simple expense tracker app but I am not able to figure out the formula with IF expression.

If value of column 'Transaction type=‘Debit’ then it should get subtracted from previous Balance column value. How to apply formula so that I get the correct Balance amount.

Please don’t create duplicate posts. Thank you!

How to subtract Debit column value from previous B… - Google Cloud Community