1 Reply Latest reply on Oct 23, 2012 7:32 AM by Kristofer Still

# How do I preserve number formatting when I am converting a number value to a string?

I have a dashboard where I want a set of measures to be displayed in a very specific way and because I don't like how it looks as a Tableau table I tried to concatenate it together as a string field. However when I convert my values to strings the number formatting isn't preserved and I end up with scientific notation and long strings of decimals.  Is there a way within my formula to preserve the number formatting I have the field set to?

This is the string I want:

To Date

\$74.9M (67%)

Here is the formula:

STR(SUM([Sales]))+" "+STR(([% of Forecast]))

And what Tableau returns:

To Date

74.89762e+006 0.666666666

[Sales] is set to 0.0M  and  [% of Forecast] is a custom percentage, 0 decimal with the ()'s  - (0%)

• ###### 1. Re: How do I preserve number formatting when I am converting a number value to a string?

You will have to do the formatting manually before turning it into a string...

Try this formula:

"\$" + STR(ROUND(SUM([Sales])/1000000,1)) + "M (" + STR(ROUND([% of Forecast])*100,0) + "%)"