KNOWLEDGE BASE

How to Set the the Number of Decimal Places After Changing the Decimal Number to String in Tableau Desktop/Prep


Published: 14 Feb 2024
Last Modified Date: 15 Feb 2024

Question

After changing the decimal number to string in Tableau Desktop/Prep, the number of decimal places is very large for some numbers.
For example, the String type number shows [.99999999999999999994] or [.0000000000000001] as a string.
User-added image

Environment

  • Tableau Desktop
  • Tableau Prep Builder

Answer

Please use the calculation below to set the number of decimals in a String type.
STR(INT([Value]))
+ "." + 
RIGHT(STR([Value]*100),2)
Please change the numbers in the last lines to set the number of decimals. e.g. for 3 numbers, please use [RIGHT(STR([Value]*1000),3)].

The results are as follows.
User-added image

Please also check the attached workbook for details.

 
Did this article resolve the issue?