Get SUM result depending on filter result

Hi,

I’m working on creating General Ledger sheet as following:

How can I make SUM function of DEBIT and CREDIT columns works depending on filter of ACCOUNT NAME as following:

P.S. By default SUM function doesn’t affect on filter result.