Weighted sum of a list from an API


I’m doing a database search where the result is a list of numbers, I need to multiply each number per a coefficient of their own, then summing the whole result.
Everything is done from an API Workflow.

Example of application : The detail of an ecommerce order is pushed to Bubble through an API Workflow, each product only appears once in the list, but is combined with a quantity.
I need to mutlitiply each product price (prices are stored in my database) per their quantity and then sum the result to obtain the order total.

It seems easy on the paper, but I’m really struggling as I can’t use the “*” operator on a list of number before doing a :sum :frowning:

Thanks you very much for your help !

Up someone? :pray:

I think you will need to trigger an API Workflow on a list.

1 Like

Bubble has a built-in sumproduct function (based on user request a few years back).

You trigger it first by selecting Calculate formula:


then Calculate SumProduct:


Where you input your list’s prices as List 1 and your list’s quantities as List 2, and then the output will be the sum of each item’s price * quantity.


Thank you very much Edd, I think this is exactly what I was looking for !

This topic was automatically closed after 70 days. New replies are no longer allowed.