1 Reply Latest reply on Oct 21, 2016 12:20 AM by Łukasz Majewski

    How to create a date range using the Data Source filter?

    Michael Szymanski

      Hello,

       

      Let me start from the beginning  My data source is an Oracle data base. I am using an Inner Join to the date field from the DISASTER table to the date field in the TIME_DIMENSIONS table.
      See the attached picture. The "Data Source" is the DISASTER table (custom sql) with the date field "DT". The TIME_DIMENSIONS table is a straight table (Oracle database). Think of it as a calendar table. What I want to do is have DT <= DAY AND!!! DT + 90 >= DAY. So this is a date range of day one to day ninety with day one being the DT field from the DISASTER table. I can do the DT <= DAY BUT!!! I cannot do DT + 90 >= DAY. Tableau will not let me add that "+ 90" to the drop down field for DT.

       

      So now I know I must make a join on DT = DAY straight forward in the join window.  Then I must use the data source filter so that  performance will be improved as it will initially filter the data and return thousands of records and not millions.

       

      Now.  How do I create this calculation in the data source filter I cannot filter on DT and DAY in the same (one) filter.  I have noticed the NOW() function in Tableau acts like SYSDATE in Oracle.

       

      Could I use a formula like:  DT <= NOW() and DT + 90 >= NOW()

       

      or do this

       

      Follow this steps for DT
      1. Right click on data source and select edit data source filter option
      2. Click on Add and select DT
      3. Now select relative date option
      4. Under the relative date option select Months
      5. And then set last 3 months  (last 90 days)

       

      Thanks for your help.  First time using data source filters and I am not good with date ranges.

       

      Michael