How to sum comlum values in datatable using where condition

I am using MySQL to sum data then display it in datatable but since database is bigger it became very slow I am trying a new approach where I use client side to do calculation, tried every code I could find but keep getting this error :

$(...).DataTable(...).column(...).data(...).sum is not a function

I need to sum all values of column(5) where column(1) value = column(2) value