Limiting decimal digits within expression

I am using a Valid If expression in an enum type to create a dropdown of dollar values based on percent markup of the column “A Table” within that row using the following expression:

LIST(
CONCATENATE("5% - ",[A Table]*1.05), CONCATENATE("10% - ",[A Table]*1.10),
CONCATENATE("15% - ",[A Table]*1.15), CONCATENATE("20% - ",[A Table]*1.20),
CONCATENATE(“25% - $”,[A Table]*1.25)
)

@Suvrutt_Gurjar helped me with the yesterday. It works great, except because the base type must be text, there are too many decimal digits (screenshot attached). Is there a way, within the expression itself, to limit the decimal digits to 2?

The implication in the TEXT() function is that if you wrap it around a Decimal type it will truncate it to 2 decimals.

I think there may also be a DECIMAL() function but i am not seeing any documentation on it.

I just looked in the Expression Assistant, there are no parameters to control decimal digits in the DECIMAL() function. Its strictly a conversion function to convert TO Decimal.

2 Likes

Awesome, wrapping each [Column] value with TEXT() did the trick. It also added the $ back in for some reason so I could delete it from the equation. It ended up looking like this:

LIST(
CONCATENATE("A Table - ",TEXT([A Table])),
CONCATENATE("5% - ",TEXT([A Table]*1.05)),
CONCATENATE("10% - ",TEXT([A Table]*1.10)),
CONCATENATE("15% - ",TEXT([A Table]*1.15)),
CONCATENATE("20% - ",TEXT([A Table]*1.20)),
CONCATENATE("25% - ",TEXT([A Table]*1.25))
)

Thanks again!!

1 Like

Yes, retaining the $ is the expected behavior for the TEXT() function. You can think of it as grabbing the display value from a column, reduced to 2 decimal digits.

Unfortunately, if you needed more precision that 2 decimal digits, the TEXT() function is not going to help.

1 Like