1 2 3 Previous Next 31 Replies Latest reply on Apr 27, 2015 11:18 AM by Jared Raymond

    How do I classify groups based on date calculations from converted/parsed dates?

    Jared Raymond

      I watched the Tableau training video on date calculations and reviewed the forum questions on date calculations/conversions but I'm still having trouble.


      I want to classify data into 2 groups. Let's say "E" and "A". The classification into these groups is based on the difference between Date 1 and Date 2. By definition, if date 2 is the same year as date 1, then it's group E, otherwise it's group A. (Date 2 can't be before Date 1 by definition)


      The problem is that date 1 is yyyy and date 2 is "mm-dd-yyyy 12:00:00 AM" I want to say that if date 1 and date 2 (just the yyyy) are equal, then it's group E, if not, then group A.


      I tried parsing the dates since they were originally strings.


      Date 1 Field: (DATEPARSE("yyyy", [field name 1]))   (field name edited)        

      Date 2 Field: DATEPARSE('yyyy', RIGHT([field name 2],4) )    (I was hoping that the 12:00:00 AM wouldn't matter and that the right four would just count the yyyy)


      Then I created the two groups


      A: If DATEDIFF('year', [Date 1 Field],[Date 2 Field]) = 0 THEN 0 ELSE 1 END

      E: If DATEDIFF('year', [Date 1 Field,[Date 2 Field]) = 0 THEN 1 ELSE 0 END


      This should classify each applicable instance as an E or an A, and I wanted to count the E's and A's, but this seems to classify everyone as an A regardless of the information.


      Any ideas? I'm probably over thinking this.

        1 2 3 Previous Next