Category: Widget
Resource links
Updated

This solution is summarized from an archived support forum post. This information may have changed. If you notice an error, please let us know in Discord.

Get Sum of a Table Column in a Label

Issue

I need to calculate the total of a specific column in a label in my Appsmith application. I am using a table widget with client-side pagination. When I change the page, I want the label to update with the page-wise total dynamically. I also need the label to update when I apply sorting or filters from the client-side.

Resolution

To calculate the total of a specific column in a label for a Table widget, follow these steps:

 

For Server-Side Pagination:

  • You can write a query to calculate the total directly in your database, and use that result in the label.

     

For Client-Side Pagination:

  • Use the lodash function sumBy to calculate the total of a specific column from the table data.
Example 1: To Sum the "Visa" Column
  • Use the following code to sum the "Visa" column across all pages:

    {{ _.sumBy(table1.data, (row) => row.Visa) }}