3 Replies Latest reply on Aug 22, 2016 1:12 PM by Mike Burke

    Conditional Date Filters in a single graph

    Periyasamy S

      I have two columns. one is last date of month and the other is total number of orders until that month.

        

      End_of_monthorders_count
      10/31/201420
      12/31/201430
      7/31/201540
      10/31/201550
      12/31/201560
      4/30/201670
      5/31/201680
      7/31/201690
      8/30/201699

       

      I want to show this in a graph with year vs orders_count

      The conditions are

      IF (Year(End_of_month) < Year(Today)) then show the orders_count for december alone

      else if  (Year(End_of_month) = Year(Today)) then show the orders_count for the lastest month.

      Can someone help me with this ?

        • 1. Re: Conditional Date Filters in a single graph
          Mike Burke

          I am thinking there is an easier way to do this.  You can change the aggregation of a measure by right clicking on the measure > Default Properties > Aggregation.  Choose Maximum and when you plot the years it will only show the maximum order count for that year.  Since it's cumulative this should work.  The other option would be to do the calculation in your data source or finally you could do it in Tableau.  The attached might help.  Best of luck,

           

          Mike

          • 2. Re: Conditional Date Filters in a single graph
            Periyasamy S

            Thanks Mike for your timely reply.! ... But I wanted the solution to be more generic. Is there anyway to get it done without hardcoding the exact date in the calculated fields ? (Becoz, I may have endofmonth starting from 01/31/1988.. In this case, I may then end up having more  calculated fields)

            • 3. Re: Conditional Date Filters in a single graph
              Mike Burke

              Changing the default aggregation of the measure to max solve this.  The alternative was to create those calculated fields, which I agree is optimal and not necessary. I probably should have left that alone to keep things straight forward.

               

               

              Let me know if changing the aggregation to Maximum doesn't work.

              1 of 1 people found this helpful