1 Reply Latest reply on Mar 10, 2014 1:05 PM by Jeff Strauss

    Extract with or condition

    Jeff Strauss

      Here's what should be an easy one for the Tableau jedi's of the world.  How do I create an "Or" condition when creating a data extract.  I have successfully done it via the custom SQL, but prefer to stay away from this because it takes a long time to generate the metadata on a large SQL.

       

      Here's an example from my custom SQL

      WHERE

        (agg_dim_coordinate_filtered.time_type_code not in ('D', 'W', 'CW'))

        OR (agg_dim_coordinate_filtered.time_type_code in ('D', 'W', 'CW')

                  AND agg_dim_coordinate_filtered.time_period_start_date >= CURRENT_DATE - INTERVAL '3 years')

       

       

       

      Thank you!

        • 1. Re: Extract with or condition
          Jeff Strauss

          I think I figured it out myself by putting the following formula on the time_type_code.

           

          RAWSQL_BOOL("(agg_dim_coordinate_filtered.time_type_code in ('D', 'W', 'CW')

          AND agg_dim_coordinate_filtered.time_period_start_date >= CURRENT_DATE - INTERVAL '3 years')

          OR (agg_dim_coordinate_filtered.time_type_code not in ('D', 'W', 'CW'))

          ") == TRUE

           

           

          It turns into:

           

          WHERE (((agg_dim_coordinate_filtered.time_type_code in ('D', 'W', 'CW')

          AND agg_dim_coordinate_filtered.time_period_start_date >= CURRENT_DATE - INTERVAL '3 years')

          OR (agg_dim_coordinate_filtered.time_type_code not in ('D', 'W', 'CW'))

          ) AND (1 <> 0) OR NOT ((agg_dim_coordinate_filtered.time_type_code in ('D', 'W', 'CW')

          AND agg_dim_coordinate_filtered.time_period_start_date >= CURRENT_DATE - INTERVAL '3 years')

          OR (agg_dim_coordinate_filtered.time_type_code not in ('D', 'W', 'CW'))

          ) AND NOT (1 <> 0))

          1 of 1 people found this helpful