1 Reply Latest reply on Jun 11, 2016 3:19 PM by Sharad Adhikari

    Current Month, Previous Month and Year to Date

    Kurt Hagen

      I'm new to tableau and a little lost how to make a date filter work. This is my problem...

       

      SaLes database has a date field called Entry_Date

       

      i would like to add a filter to my dashboard with 4 values in a drop down...

       

      Current Month

      Previous Month

      Year to date

      Full year to date

       

      The filter would always select records for this year and last year based on the following logic...

       

      Current Month = current month this year and same month for previous year.

      i.e. If today is 6/15/2016.   The filter would select ALL records for June 2016 and June 2015. I am not worried about day of the week

       

      Pevious Month = month of today()-1. Again - need records for current year and previous year

      i.e. If today is 6/14/2016. The filter would select all records for May 2016 and May 2015

       

      Year to Date = Jan 1st -> previous month. I only want records for months that have completed so I'm using Previous Month instead of Current Month as my end date.

      I.e.  If today is 6/15/2016.  Filter would select records for Jan-May 2016 & Jan- May 2015

       

      Full Year to Date = just group records by year. This will give me all records for this year and all records from last year.

       

      I'M hoping this can be accomplished with a single long case select statement.

       

      THanks in advance. Love the Tableau community.

        • 1. Re: Current Month, Previous Month and Year to Date
          Sharad Adhikari

          Hi Kurt,

           

          I would do the following.

           

          1. Create parameters.

          Parameters.JPG

           

           

          2. Create field for your first column.

          First field.JPG

           

          3. Create field for your second column.

          Second field.JPG

           

          4. Create view using these two calculated columns and use the parameter.

           

          I did try with the superstore data and it was missing 2016 data, so you might have to tweak the calculations. I would have shared the workbook but I tested it on 10 beta.

           

          Best of luck.

           

          BR

          Sharad