8 Replies Latest reply on Nov 28, 2018 1:25 PM by Joe Oppelt

    Expected end to match case at Character 0'

    patty.yang

      Hello Dear Tableau community,

       

      Upon my research trying to figure out the 'Expected end to match case at Character 0' error....well I gave up, and I am hoping someone has the better knowledge to help me figure out where I did wrong.

       

      Here is my calculation statement, 'Select a Measure' is between count and percentage. And I need the number format to be dynamically displayed also. Count using whole number and Percent is percent with two decimal with a '%' sign.

       

      case [Select a Measure]

      WHEN 'Count' then

      if attr([Outcome Year]) = 'After Year 1'

      then sum([Attrit After Yr 1])

      ELSEIF attr([Outcome Year]) = 'After Year 2'

      THEN sum([Attrit After Yr 2])

      ELSEif attr([Outcome Year]) = 'After Year 3'

      THEN sum([Attrit After Yr 3])

      END

       

      WHEN 'Percent' then

      If attr([Outcome Year]) = 'After Year 1'

      then STR(ROUND(SUM([Attrit After Yr 1])/TOTAL(SUM([Attrit After Yr 1]))*100,2))

      ELSEIF attr([Outcome Year]) = 'After Year 2'

      then STR(ROUND(SUM([Attrit After Yr 2])/TOTAL(SUM([Attrit After Yr 2]))*100,2))

      ELSEIF attr([Outcome Year]) = 'After Year 3'

      then STR(ROUND(SUM([Attrit After Yr 3])/TOTAL(SUM([Attrit After Yr 3]))*100,2))

       

      else null

       

      END

       

      I really don't know where the error is. Thank you guys for your help!!