4 Replies Latest reply on Mar 21, 2017 2:19 PM by Michael Johnston

# Round and Str - please explain

I have found many posts but still confused on why it's doing it and why using MAX() will fix the problem.  I have attached a workbook to demonstrate what I am talking about.  I want to understand it so I know this "MAX()" fix will always work and it's not just by chance it's working because of the data I have.  I am currently using Tableau Desktop 10.0 Thanks.

I am using the following 2 calculations:

"Percent String - not rounding " calculation:

IF ([Denominator]) = 0 THEN 'N/A'

ELSEIF ([Numerator] / [Denominator]) < 0.1 THEN '< 0.1%'

ELSE STR(ROUND(([Numerator] / [Denominator])*100, 1)) + '%'

END

Percent String - correct

IF MAX([Denominator]) = 0 THEN 'N/A'

ELSEIF MAX([Numerator] / [Denominator]) < 0.1 THEN '< 0.1%'

ELSE STR(ROUND(Max([Numerator] / [Denominator])*100, 1)) + '%'

END

Item Percent String - not rounding Percent String - correct
 Denominator
Numerator
Item 1  < 0.1%  < 0.1%1,0001
Item 2N/AN/A00
Item 310%10.0%1,000100
Item 4 53.100000000000001% 53.1%
 999
530
• ###### 1. Re: Round and Str - please explain

I probably has more than i row per item.

• ###### 2. Re: Round and Str - please explain

No, my data set only has 4 rows - a row for each item and there is 4 items.

• ###### 3. Re: Round and Str - please explain

My mistake.

I'm seeing now.

It seems to be a bug.

I've tested without STR and calculations are fine.

• ###### 4. Re: Round and Str - please explain

I'm having the same issue here trying to convert a state's min wage from a number to String so I can concatenate with the state abbreviation.

I suppose I'll have to do two fields instead.