To sum a column use: =SUM(A1:A20). But what if the column is filtered?

As you can see , in the picture below, the sum function sums all the values, even the ones filtered out. To solve this problem use: =SUBTOTAL(9,A1:A20)

Functions:
=SUM(number1;[number2];...)
Adds all the numbers in a range of cells

=SUBTOTAL(function_num;ref1;...)
Returns a subtotal of a list or database