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

    Round and Str - please explain

    Amy Sheu

      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