Round to nearest in table

I have a table like this:

#4 (per stuk) is the total amount of the part (raw material) divided by the quantity to make for this order. Works fine, but sometimes I get a output like 410.111111111111 - and I would like to round that to 410.1

These 2 fields (parts_booked & quantity) are a string by default, and I tried to change it to number like this:

But as soon as I save that, nothing changes in the field expression, it stays: parts_booked / quantity. When I reopen with the magic wand, the value type is back to string again.

Also I have tried adding .toNumber() to the field expression, but then it gives an empty table column.

Hello Nevil,
You don’t change the data type from there. There is a formatter called “To Number” which makes your string value a number.
So first apply the To Number formatter to the value and then round it :slight_smile:

And please do this on the page, not inside the table generator.

Please read the last line of my post, I have already tried that.

And what do you mean do this on the page? Because it’s a table.

Generate your table and then when it is generated on the page apply any of the formatting options you need (not in the table generator dialog).

Expression is now: parts_booked.toNumber() / quantity.toNumber()

But that returns no values. Should I use quotes or parentheses somewhere?

Please paste the whole expression with the tag it’s applied on/in.
Also, please open your browser console and check for warnings.

Not sure what you mean by whole expression, and tag. This is the code:

This is the error in the console:

parser.js:752 Formatter toNumber doesn't exist for type number

By the expression and its tag, I meant the <td></td> that’s called an HTML tag.
The expression is the dmx-text… part

The warning in the console says any (or both) of your values are numbers and not strings. So you can’t add to number formatter to a value which is already a number.

But it says here it’s text:

What should I do now? I still want to round the output number

Please provide a link to your page, where i can see what the data returned actually is.
Or simply try:

(parts_booked / quantity).round(1)

Teodor's solution should work

You can also use the toFixed formatter

(parts_booked / quantity).toFixed(1)