How do you multiply a list of numbers by 100?

I have a list of numbers in a repeating group
(0.31, 0.05, 0.77)
I would like to multiply each of those items by 100 and get another list of number so I can use it on a graph. I can do math on a single item but I can’t do math on a list of numbers :frowning:

Unfortunately, it’s a lot more difficult to do than you would expect, but this post should help:

I wasn’t able to replicate this step

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

How can I divide by 10 when that item is a text and not a number? Bubble gives me the option to turn it uppercase, extract, count characters, etc (all stuff about text) but I cant do math on a text

Are you able to do that step?

It might be difficult for me to help without having a look at your editor. Happy to jump in and take a look if you want to pass on a link.

If your original list is a list of numbers, then when you use the :format as text operator on the list, the top input box should provide an option that says “This Number”. You can then put the expression This Number * 100, and follow the rest of the steps in the linked post.

I would first try adding a repeating group of type number and in the datasource you will create the dynamic expression that starts by referencing the list of numbers you want to multiply by (maybe that is from the DB or another RG) and then in that same dynamic expression say each items number multiplied by 100

Obviously, you can’t perform mathematical operations (directly) on text…

But you said you had a list of numbers (not a list of texts)??

But, if you have a list of texts instead, then you’ll first need to convert each text to a number… which you can do either by converting the list of texts to a list of numbers (using each item converted to number), or by formatting the list as text, and using This Text converted to number (then multiplied by 100) in content for the list item.

So, if you do have a list of texts (and not a list of numbers, as you stated in your original post), the full method will be the following:

  • List of texts: each item converted to number - (to produce a list of numbers)
  • Formatted as text (to enable you to manipulate each item in the list separately)
  • This number * 100 (comma delimited) - (to multiply each number in the list by 100 - this will output a single, comma delimited text)
  • split by (,) - (this will split the single output text into a list of texts)
  • Each item converted to number - (this converts the list of texts to a list of numbers)

Unfortunately, there’s no such thing in Bubble as each item's number multiplied by anything… (each item’s number will output a single text)

Bubble can’t do even simple list maths, without resorting to the (unnecessarily complicated) method above, as it doesn’t have even basic programming functionality like mapping, or looping (the :format as text operator is the closest thing we get).

Of course, in JavaScript, the above is as simple as:

let multipliedNumbers = => num * 100);

So personally I’d use that, and store the output list in a JavaScript to Bubble element.

1 Like

I got your original post to work

What I was doing wrong is that I was using the :each item:fomatted as text option as opposed to the :format as textoption

thanks for the help

1 Like

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