Having difficulty showing two decimal places in text formulas. Bug?

I have a decimal field in Xano that I’m using in a text formula. If the value in Xano does not have a hundredths value, the text formula is not showing those trailing zeros, even when using a rounding function to 2 decimal places. Is this a bug?

FWIW, if I try to trick it by adding 0.001 to the Xano value (eg. round(20.5+0.001)), it still won’t show the last zero. But if I add 0.005, it will show 20.51.
Screenshot 2023-09-15 163153
Screenshot 2023-09-15 163259

I should clarify, this behavior occurs with a Xano value with no tenths value too.

Hi @ericp :wave:

I’m struggling to understand what’s working and what isn’t.

Can you tell me the results you have for different values in Xano?

For example:

  • 420.5 in Xano => displays 420.5 correctly in WeWeb
  • 420.56 in Xano => displays x in WeWeb but I want to display 420.6
  • 420.001 in Xano => displays x in WeWeb
  • 420 in Xano => displays x

It’ll help me reproduce your use case on my side and hopefully find a solution for you :slight_smile:

Hi Joyce,

I’m trying to get a Xano value of 20.5 to display as 20.50 in WeWeb inside of a text field that provides context to what the currency value is related to. Thought using the rounding function with 2 decimal places would do the trick, but it does not.

Eric

Aaaah ok, got it! I was tying knots in my brain :sweat_smile:

Mmm it looks like something we could improve on our side. I’ll share with the team.

In the meantime, something like this should work:

Here’s the Javascript equivalent if you prefer that approach:

return (Math.round(number * 100) / 100).toFixed(2)

Just make sure you replace the number parameter by whatever variable or item data you are getting your number from.

So for example in my project, I’m using the custom formula I created in no-code above and binding it to my item data coming from a Xano collection:

2 Likes

Thank you once again Joyce, the no-code formula works for me.

1 Like