6 Replies Latest reply on Dec 16, 2016 10:23 AM by Jim Dehner

    How to get tableau to use whole data set on IF/ELSEIF function or something similar

    kirstie townsend

      Hi All

      I apologies if this sound confusing.


      I have a data set with Open And Closed Dates


      I want to know how many records where open at the end of January, irrelevant of if they are now closed. My calculated field is this:


      IF [Open Date] <=Date("31/01/2016") AND [Closed] >Date("31/01/2016") THEN "Open in Jan" ELSE "other" END


      Now i know that this will bring back only records where it is closed (this is fine) but what i want to do is extend this calculation to tell me also how many records where also open at the end of February. for example


      IF [Open Date] <=Date("31/01/2016") AND [Closed] >Date("31/01/2016") THEN "Open in Jan"

      ELSEIF  [Open Date] <=Date("29/02/2016") AND [Closed] >Date("29/02/2016") THEN "Open in Feb" Else Other END


      Now this calculation works fine for JAN but the records that don't fall into the JAN category will then go through the FEB calculation, where as i need the whole data set to go through the FEB calculation.


      Is this possible to do in 1 calculated field or is it not possible?


      Unfortunately i am unable to attach any workbooks or examples due to the content of the data i am using


      Thanks in advance