3 Replies Latest reply on Nov 9, 2016 11:26 AM by Marc MOUSSA

    Using if then statement within an If Then statement

    Theodore Kim

      Hi, I'm trying to figure out making a set of strings into date format (for example, one string is 1012016 which should be 10/1/2016) for Tableau to read as dates. Because there isn't a single format for the number of numbers in the string, I've decided to use an if then statement.

      IF LEN([Date]) = 7 THEN

          (IF LEFT([Date],2) = "10" OR

          LEFT ([Date],2) = "11" OR

          LEFT ([Date],2) = "12" THEN DATEPARSE(MMdYYYY, [Date])

          Else DATEPARSE(MddYYYY,[Date]))

      ELSE Len([Date])=8 THEN DATEPARSE(MMddyyyy, [Date])


      The error I'm getting is "Expected 'end' to match 'if' at character 31. Can anyone help figure out what's wrong?