Calculations and saving to DB

Just when I thought I was mastering Bubble. This has to be easy but I’ve never done this before…

I have a user that can create multiple goals. Each goal has a pledge amount to be donated if goal is not completed. I’d like to show the total amount pledged (sum of all goals) as well as total amount donated (goal = failed) and amount saved for successful goals.

I have created a “Stats” that has TotalPledged, TotalSaved, Totaldonated data attributes.

What’s the best and most efficient way to create, calculate and save those values to the DB? Should It be a DB value or is the approach to render it in broweser?

Any help would be appreciated!!

Hi @zachary.dorsch ,

It sounds like your Goal data type is all you need as long as you have the following fields:

  • Status (option set: success, fail)
  • Pledge Amount (number)

Now you can calculate on the page without needing to go through a Stats type:

  • Total Pledged = Search for Goals’s Pledge Amount :sum
  • Total Saved = Search for Goals (Status = success)'s Pledge Amount: sum
  • Total Donated = Search for Goals (Status = fail)'s Pledge Amount: sum

This should get you going in the right direction!


Cheers, Gaby
Co-Founder at Coaching No Code Apps
Free Bubble Masterclass
Private Help

1 Like

@romanmg Wow, I really tried to overcomplicate that. This was exactly the solution I was looking for. :slight_smile: Surprised I haven’t encounter this before now .

Is there ever a time that I would need to do some back end calculation and save a value to the DB to reference? As far as performance goes? Just curious

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