# footer total using two columns

# footer total using two columns

montoyam
Posts: 568Questions: 136Answers: 5

I am having trouble understanding how to use data from two columns together for the footer. The examples given use something like this:

```
total_WAN = api
.column(1)
.data()
.reduce(function (total, num) {
return intVal(total) + intVal(num);
}, 0);
```

however, what I need to do is to sum (column(1)*column(2))

from what I see, the reduce function will only work with one column?

This question has an accepted answers - jump to answer

This discussion has been closed.

## Answers

One way is to get the sum of the other column then add the two together for the footer.

Kevin

no, i can't do that. one column is the count of users. the 2nd column is a 1 or a zero. The sum needs to be a sum of all the (count x 1) + (count x 0).

hope that makes sense. you can't just add the two and multiply or add them.

In that case I would use

`filter()`

to filter the rows where the 2nd column is 1 and chain`pluck()`

to get the values in column 1 into an array using`toArray()`

. You can then sum the array using`reduce()`

. Here is an example that generates an array of Names that are in the`London`

Office.http://live.datatables.net/yewikige/1/edit

Kevin

yes, that worked perfectly!! Thank you