3 Replies Latest reply on Feb 22, 2017 12:34 PM by David Li

    Double Equal Sign (==)

    Matthew Boyd

      All, can someone please help me, and others, understand the use of the double equal sign (==) in equations used by the community? What word(s) would you replace this with if you were talking to someone? For instance, (<=) translates to "less than or equal to" in a sentence. However one would not say "equal to or equal to".

       

      Formula example:

      (YEAR(MIN([Date])) == YEAR([Max Date])-1

      AND MIN([Date]) <= DATEADD('year',-1,[Max Date]))

        • 1. Re: Double Equal Sign (==)
          David Li

          Hi Matthew! I think the reason Tableau accepts both (and why some people prefer to use it) is because a number of programming languages use == as the equality operator and = as the assignment operator.

           

          For instance, in JavaScript, you must use the double equals sign to compare two values. You can't use the single equals sign, because that's an instruction to assign a variable to some value.

           

          if (myNumber == 7) {
               myNumber = 1;
          }
          

           

          This code would change a variable named myNumber from 7 to 1.

           

          In Tableau, there's no difference between a single equals sign and a double equals sign because you can only assign the value of the particular calculated field that you're editing, so there's no chance for ambiguity.

          9 of 9 people found this helpful
          • 2. Re: Double Equal Sign (==)
            Matthew Boyd

            Thank you for the clarification David! Much appreciated!

            • 3. Re: Double Equal Sign (==)
              David Li

              You're welcome!