Extract with "or" condition

Version 1

    Description:

     

    Here's a SQL that I wanted to replicate within Tableau using extract filters, but was unable to.

     

    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')

     

     

     

     

    Solution:

     

    I created a calculated boolean and selected true as part of my filter.

     

    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

     

    The result is that Tableau passes this as is to your DB, but adds a little.  Looking at the logs, it translates it into this which is still workable:

     

    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))

     


    Comments:

     

     

     

     

    Related Functions:

     

     

     

    Further Reading/Examples: