7 Replies Latest reply on Sep 17, 2016 5:03 PM by Vishal D

    Filter while adding datasource?

    Vishal D

      I have a datasource which has field 'Report Year' = [1997, 1998, 1999, 2000, ........, 2015, 2016]

       

      When I add this datasource I want to filter the data and get data only for 2010 and greater.

       

      I dont want to hardcode the years since its dynamic field and next year I will see 2017 here.

       

      How do I filter?

        • 1. Re: Filter while adding datasource?
          Mark Holtz

          Vishal,

          If you are comfortable with it, you could utilize a custom SQL statement to issue against your underlying database/source which could limit to some dynamic period retroactive from the system date. In T-SQL for a query against a Microsoft SQL Server database this would be something along the lines of

          "WHERE [DateField] >= DATEADD(yy,-6,GETDATE())"

           

          If you aren't comfortable with or cannot issue custom sql, you can also use a Tableau Data Source Filter. Since you're referencing a year, you would not have to update it very frequently.

          Filter Data from Your Data Source

          1 of 1 people found this helpful
          • 2. Re: Filter while adding datasource?
            Vishal D

            Mark,

             

            Where will i write the SQL statement? Also I need anything >= 2010 and not limit my self to 6 years as the years will keep growing.

             

            I dont think I can use static data-source filter and dont want to end up supporting the dashboard each year:)

            • 3. Re: Filter while adding datasource?
              Ivan Young

              Hi Vishal,

              While custom sql will work for filtering the data source it isn't really necessary.  You can just use a data source filter (see screenshot below).

               

              Click on 'Add' then select your field.  If it is a true date you will want to create a relative date filter with a starting date.  If the year is numeric use the condition tab and set by formula year >= 2010

               

              Let me know if you have any questions.


              Regards,

              Ivan

               

               

               

               

              • 4. Re: Filter while adding datasource?
                Vishal D

                If I do relative date this is what I get.

                 

                What do I select here?

                 

                • 5. Re: Filter while adding datasource?
                  Dmitry Chirkov

                  Click on rectangle Years button and then pick "Last N years" option.

                  • 6. Re: Filter while adding datasource?
                    Ivan Young

                    Hi Vishal,

                    If you want to see the last seven years always, then Dmitry's suggestion should work perfectly.  For this year you would see 2010-2016, beginning next year you would see 2011-2017.

                     

                    If you want 2010 to remain included in 2017 you should use Starting Date.  You would click on the Starting Date box and set to 1/1/2010.

                     

                     

                    Let me know if you have any questions.

                     

                    Regards,

                    Ivan

                    • 7. Re: Filter while adding datasource?
                      Vishal D

                      while this works great if I have a date to filter.

                       

                      I have another datasource where i dont have date but 'Report Year'

                       

                      I have a datasource which has field 'Report Year' = [1997, 1998, 1999, 2000, ........, 2015, 2016]

                       

                      When I add this datasource I want to filter the data and get data only for 2010 and greater.

                       

                      I dont want to hardcode the years since its dynamic field and next year I will see 2017 here.

                       

                      How do I filter?