Forum Academy Marketplace Showcase Pricing Features

Create Variable To Aggregate Data

Hello beautiful Bubblers!

New to Bubble but wondering if I could create variable = data y + data x etc.

Context: I’m building an online learning patlform

Right now I have fields for every lesson a student completes:

L1 = 1, when student completes lesson 1
L2 = 2, when students completes lesson 2
Etc.

I want to create a variable called Completed Lessons = Sum of L1 + L2 + … + Ln

How would I create a variable like this?

Thank you in advance! :grin:

Best,

Andy Anderson Andreeson Horowitz IV

Yes, it’s possible to do that. It’s just a text field. Where you store the text field could be:

  • in the database
  • on a state on the page
  • on the URL

I’m guessing on the database is the best place in your case.


ps: Killer signature.

@rico.trevisan Thank you so much!

Great to know but still not sure how exactly I do it eek

For example I just made a cheeky new variable called M1

image

But how do I set M1 = [stuff] there doesn’t seem to be the option from the Data tab…

You do not need a separate field for each lesson.

Create a field on the User called Completed Lessons with type being “Lessons” and specify this field is a list.

When user completes a lesson, run a workflow to “change a thing” → change current Users → Completed Lessons add This Lesson.

https://manual.bubble.io/core-resources/actions/data-things

Rob

@andrewmitson94 I suggest you try what @robhblake mentioned but instead of making the field a list, you can simply add +1 to the number in the field. For instance, if a user is an L2 level, according to your taxonomy, the corresponding value of the data type would be “2” (number field) if they complete lesson 2. If they complete lesson 3, run a workflow that simply takes thelesson number field (in this case “2”) and do “+1”. This way you will always end up with a single number in the data field, not multiple.