Forum Academy Marketplace Showcase Pricing Features

How to show and hide decimal places?

If i have a whole number i’d like it display without decimal places (Eg $9), but if there are cents included i’d like for 2 decimal places to show (Eg, $9.20), is this possible?

Thank you

1 Like

Something like this should work. Idk if it’s the optimal route necessarily though. Checking if your number modulo 1 basically checks if it’s divisible evenly by 1. If there’s a remainder, it will not be zero, and then you can use :formatted as text to control the display for each outcome.

Also, disregard where my number is coming from. I was just throwing in something for the screenshot lol (a :count will never have a number with decimals lol)

1 Like

Hey mate,
I gave that a go but it still seems to want something after the format as text, any ideas?
image

You’re setting a Condition in this screenshot so you need something that’s going to evaluate as a yes/no. I think you either want to put this in the Appearance tab or put this formula in under the Property to change > text field.

1 Like

Doing a conditional statement though is definitely another way you could do this. Have your default text be with decimals, then made a conditional for When modulo is 0:format without the decimals. I think the performance difference would be negligible but maybe one of the performance gurus can chime in.

1 Like

Worked like a charm, thanks mate

1 Like