Use checkbox selection for calculation

I have a use case to calculate total_amount. The formula to calculate this needs to be dynamic.

total_amount = column1 + column 2 + column3. + ...

I have a filter with checkbox (allowing multiple selects). Users are provided the option to select the list of columns in a drop down list. Based on selection total_amount should be calculated.

eg. if in the filter user selects column 1 and column3 then total amount = column1 + column 3
if user selects column 1, column2, column3 in the dropdown then total_amount= column1 + column2 + column3

I am using sql and want to know of a way to achieve this .

Can’t you do a gui query and a custom column?

Is there a way to dynamically calculate a formula for a custom field?
A check box with values c1, c2, c3, c4 (all are checked by default)

total_amount = c1+c2+c3+c4 is the expression.
Whenever user unchecks any value in the filter that should be excluded from expression

eg. user unchecks c3 from the filter. Now the total_amount = c1+c2+c4

From what I have explored, Allowing multiple items to select from checkbox is only possible using a field filter. Are there any other ways