How to sum the values of a Supabase column in Flutterflow

If you are working with data within your Flutterflow apps, at some point you are going to need to provide the user with the sum of values with a column of your Supabase tables. Although there is easy way of doing this built into Flutterflow, in this video, we can see how to achieve the result relatively easily with a custom action and a stored Postgres function.

Sum column values workflow

In the video you will see that in the example we are calling a custom action on page load to display the sum of a column value to our users automatically in their dashboard. The custom action passes the parameters we need to filter the data we are calculating into Supabase, which uses the stored procedure to calculate the value and pass it back to Flutterflow. The returned value of the custom action we are then displaying in a text object as the page loads.

Here is the video tutorial. All of the custom code used in the video is available below.

Custom code

To call the Supabase function that sums the values of a column, use this code in your custom action. Remember to replace all function names and parameters with the values you are using.

This is the Supabse function which performs the sum function. Paste it into the SQL editor and click run, which will save it in the database functions. Remember the parameters will need changing to suit your specific needs and column names.