2 Replies Latest reply on Jun 14, 2017 10:43 AM by Tom W

    Understanding date formula

    Alex Martino

      Can someone please help me understand this date formula?

       

      datepart("quarter",[Close Date])=datepart("quarter", Date("5/31/2015")) and datepart("year",[Close Date])=datepart("year", Date("5/31/2015"))

        • 1. Re: Understanding date formula
          Jay Morehart

          It might be helpful to look at this in a text editor that does bracket matching (Notpad++, Adobe Brackets, Sublime text (Tableau does this but I find it hard to see))

          but we can also see what is going on with some minor re-formatting:

          So if the [Close Date] is in Q2 (Assuming default fiscal year) of 2015 this returns true, otherwise it is false. It could be re-written as:

           

          datepart("quarter",[Close Date])=2

          and

          datepart("year",[Close Date])=2015

           

          hope this helps!

          1 of 1 people found this helpful
          • 2. Re: Understanding date formula
            Tom W

            Break it down into smaller items in your Tableau report and look at each chunk individually so you can understand it.

            I.e. create a calc, datepart("quarter",[Close Date])

            Then create another calc datepart("quarter", Date("5/31/2015"))

            and so on

            1 of 1 people found this helpful