4 Replies Latest reply on Dec 12, 2017 9:59 AM by Hari Ankem

    IFNULL vs IF ... <> (or) != null ... THEN ... ELSE

    Thomas Rones

      Note: I don't have a problem to solve, this is more of a "why is it like that?" type of question


      I was writing a calculation earlier to combine some date fields from my unioned CSVs.


      So I wrote:


      IF [posting date] <> null then [posting date] else [buchungstag] end


      ..but I didn't get the results I expected. Result: The rows for posting date were null and the rows for Buchungstag were correct.


      After fiddling around with versions  and live vs extract, I finally tried IFNULL(), which gave me the results I was expecting. Ok weird, the logic is the exact same, it is just written differently.


      So I tried it with STRING, FLOAT, and DATE... the same thing everytime. IFNULL() works, but IF [Dim] <> null then [Dim] else [otherDim] end doesnt.


      OK how about != ...nope it has the same problem as <>.


      As a another note

      If NOT ISNULL([Dim]) then [Dim] else [otherDim] works as expected



      So why is this?


      I didn't find anything about this in the documentation --Formatting Calculations in Tableau but my best guess is that the operators for does not equal ( <> , !=) NULL is somehow in-equivalent to NOT NULL... which makes sense, but I am looking for the technical answer. Encoding, etc.

      (I haven't looked in for differences in the XML yet, but I thought someone might already know.)


      See attached Workbook for examples