I often find myself wanting to show numbers to the minimum number of decimal places required like in the leftmost column in the image below.
I’d like to see an “auto” decimal precision option for any number related column types where it does this for you, without needing extra columns.
Thanks! I can get the output I need by just returning the variable in a JS column as shown. It should always return the minimum number of decimals (or none) - basically need it to remove trailing zeros but then also show just the integer in the case of 1.000
Ah ok… I got it!
This new JS code can help you:
// take the integer part
// take the decimals part as a text
if (!decNum) // the Number is integer 100%?
return intNum // shows Number and exits
// Invert decimal part
var RevdecNum1 = decNum.split("").reverse().join("");
// Convert it to Number and then to Text to remove trailing zeros
RevdecNum2 = parseInt(RevdecNum1).toString()
// Invert it again to get right decimals
var RevdecNum3 = RevdecNum2.split("").reverse().join("");
// Show your new number
Feliz fin de semana James!!