Display simple calculation on API data

Hi. I’m using data from an API which produces a number as a decimal which I want to convert to display as a percentage.

For example… The API returns 0.093434 into the text box I created but I want to multiply it by 100 to show as 9.3434 (and add the % symbol onto the end)

How would I do that?

Hi @ryanmartin02

Welcome to our community :blush:

First you need to make sure that the data from the API is number, not text

To try, please create an input with a content format "Decimal"and give any value you want to initial content

Create a text and the text will show the value of this input.

Select “Input A Value: formatted as: Percentage” and edit other information as desired.

Good luck with

Thanks for your reply.

I’ve got a couple of issues trying to follow here… How did you get the number formatting box to appear?

And also I seem to be only make this field type option appear on an input rather than straight text box. (both will display the number feed from the API)

The value you give to the placeholder is invalid, it is a field created just to show you what that input is for.

Ex: Please enter your email address here

You must give the value to the “Inital Content” field.

An example here

Oh sorry, I skipped sharing the editor link

I added the input box after reading your first reply as a way to test the app, so it’s not really what I’m trying to achieve anyway.

I don’t actually want an input box, as there’s nothing I want the user to input. I just want for Bubble to bring in the number from the API as a plain number… but I want to convert that number into a percentage.

The second screenshot is more what I’m trying to work with if possible?

@ryanmartin02

You don’t have a chance to get value from a text. Maybe there is a plugin for this.
The simplest version of your request is:

Place the value from the API in the Initial Content field in the input. Then shrink the input so that it does not disturb the design, for example 1px x 1px and hide the input with "This element visible on page load " (uncheck)

I edited the sample. Please look again.

I need to get out now. I can’t answer quickly if it doesn’t help.

Good luck

Ok, thanks for your help. I’m brand new to this and the most I’ve coded are scripts with Google Sheets (though mostly copy/pasted). Obviously with Google Sheets you can run all sorts of math functions to then be displayed on a cell. So I guess I’m tryin to replicate that onto a website instead.

It makes me wonder if there is a way to call the API data into some kind of back end of Bubble.is so that I can do with that data as I please and it then be displayed in it’s final form on the front end.

Thanks again for taking your time to help.

1 Like

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