5 Replies Latest reply on Sep 2, 2018 10:18 AM by Shinichiro Murakami

    mix if and iif statement

    John Lu

      Hi I am using tableau desktop 2018.2 and need some help with creating a calculated field mixing if & iif statements, I tried it in excel which makes sense and is correct but unable to reproduce the same in tableau.


      I am trying to compare the two percentages, A & B both will be at least 0%, and I need to write a if statement to check which is bigger. Now here is the catch, I want to have 3 conditions rather than the normal 2. First I want to check if A is greater than B and I want to check if both are non-zero,  and are the same, and third if they happen to be 0%, I want results to display 0% and else, B is better.


      Now syntax below is from excel and I just need to replace it with syntax in tableau but I can't get it to work.  Again, both % will be at least 0% but I want to separate 0% from the condition if A=B and when both non 0%.


      =IF(A1>B1,"A is better",IF(AND(A1<>0,B1<>0,A1=B1),"Same",IF(AND(A1=0,B1=0),"0%","B is better")))