Text number with commas to number

Hello! I’m trying to take a number that’s actually a type text from a JSON payload and insert it into a type number field. The issue is the number has a comma in it and make doesn’t like that. I’ve tried using formatNumber and it’s still not happy. I don’t get it.

Shared with Droplr

Thanks!

1 Like

Any love on this post?! :smiling_face_with_three_hearts:

Can you replace emptyString with just '' or ' '

Hi @Nonsuch_AP,

If you’re working with a number that comes in as text with commas (like "1,234.56"), here’s the solution:

To Convert Text with Commas to a Number: {{parseNumber(input.total_number; ",")}}

If you need the number formatted to two decimal places, use: {{formatNumber(parseNumber(input.total_number; ","); 2; "."; null)}}

Let me know if you need any further help!
If this solves your problem, please consider marking it as the solution. :+1:

parseNumber did the trick for me. However I needed to change the , to a . so that it marked the decimal point correctly. NOTE: my numbers are coming in just as the example above, with thousand separators as commas and decimal points as a period.

2 Likes

Thank you everyone! :smiling_face_with_three_hearts:

1 Like