Show aggregate of the table column


how can i show the aggregate (sum ) of a column of all rows of the table in a text below the table or if i can add aggregate row as the last row of the table ?

Hello @codenayak

Don't know about having a total row in table component, but to calc the total of a column, I'd use: {{_.sum( => d.DieselCash))}} and using displayedData makes the total updated to the table filter state.
You can use data but you need to convert as Array first using formatDataAsArray.

Hope this help

1 Like

thanks, it works.
i have another problem the sum of values are in string format so sum is concateneting the values instead of summation in number format , how do i solve this.

@codenayak it looks like your numbers are strings.
Prepend + for a fast type coercion, so in your case +d.DieselCash

I'm having a similar issue. I'm trying to display various information (such as averages and totals) of a column. I've tried to follow what you've done but I'm getting NaN.

I believe it might be because I'm using a custom column which is pulling in a value from somewhere else. But if not, could you explain to me where the formatDataAsArray is meant to go? Is it going in the same value field of the text box or elsewhere?

Hey @arkonis, I'm happy to help with this! Could you share some screenshots of your setup to better help us understand your situation?

What about if I wanted to display data on a column against like a product name instead of a box?

I have used the same code and it did work, but obviously given me the full result of the table on all products instead of organizing per product.

Hi @Rui I'm not sure if I'm following yet. Can you share more details or a screenshot of your use case? Thanks!

I have managed to find on another topic what I was after :+1:

1 Like

Can you share that here, please? I have the same question and would like to have that answer.


Hi @mathfour! In the meantime, please don't hesitate to share your exact example details! Happy to take a look

Hi, I have table and I want to have Grand Total row in it to calculate the sum of number_of_leads.
I can get the sum in the text component as attached but I can't figure it out how to add the sum to the same table? Is there a way to insert Grand Total row in table?

Hi @mondob Thanks for reaching out! We don't currently have a feature for a summary row, but this is something we're working on!

In the meantime, you could add the total to the underlying table data (or keep it as a separate component):

Hi! I have had this working but some some reason has stopped working now and can't work our why! I wanted to display on column "To be ordered for Jobs within a Month" the result of my query where it selected certain jobs that will happen in a month period and summed the quantities of products. My query is working as is giving the right results. But wanted to insert the results into the relevant row corresponding to the correct material but using the find function is returning that it's not a function so I'm lost of how to take from here. Please help.


Is there a way to make the total updated to the table current values of an editable column?
Ie: when a user updates a value in the table, the total would be updated (without having to write in the data source)


You could use the solution described in this community post to calculate the total with the un-edited data + the pending edits (.changeSet):

1 Like

Thanks @Tess,
I've tried this method but I still do not see "Total" row. What might be the problem?

Hi @mondob

BigQuery typically returns data as an object of arrays, so you can't use .push() or .map against data.

You could try adding data = formatDataAsArray(data) to the beginning of the transformer:

1 Like

Yes, it seems that it works now, thank you @Tess !
But now I don't get sum of number_of_leads. The result is undefined. Maybe you have any ideas regarding this?

I think it's because number of leads has two a's (number_of_leaads)

1 Like