How do I build an expression to alter a list of numbers?

I have an API call that is returning an array. I am loading a list of those numbers using the each items: value function in the expression builder. The list is currently: 50,100,30

I would like to scale those numbers down by 10 then add 5 to them.

Goal is a result set: (50/10)+5 = 10, (100/10)+5 = 15, (30/10)+5 = 8
Result set: 10, 15, 8

Unsure how to build an expression which does this. Any suggestions?

To do this in vanilla Bubble you can do the following:

Take the list of numbers and use the :format as text operator

For each list item, enter (This Number/10) +5 and use , as the delimiter… that will output a single string: "10,15,8"

Use :split by , to split that into a list of texts ("10", "15", and "8")

Then use :each item converted to number to convert that list of texts into a list of numbers (10, 15, and 8)


And we scream, yet again, into the void, “why don’t those chuckleheads at Bubble just add a proper :map operator to lists!?”


You nailed it! I was able to get it working first try once I read your post.

So to summarize: If you are looking so see how you can do math on a string of numbers in is simple - just convert it to text!

As to why I have to do that in order to do such a basic programming function… I am just baffled.

@josh @emmanuel Please consider closing the obvious gap here.

@mc3digital: Note that this only works because of JavaScript’s type coercion features and will work fine for many but not all use cases.

(For example, let’s say you have two lists of numbers and you want to multiply each number in list 1 by the corresponding value in list 2. For such cases, one can use the List Math action in Floppy [which also has a server-side action equivalent], or the PROCESS List action in List Shifter [now found in Floppy].)


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