2 Replies Latest reply on Jun 24, 2016 1:09 AM by Damian Lilla

    Changing database schema via parameter/filter

    Damian Lilla

      Hello dear Tableau community,

       

      Our analytical database has disjoint schemas for each instance of our application - the schemata have the same structure, but data from different sources. Our dashboard are often copy-pasted queries for each instance of our apps. We are unable to create some kind of "schema-parameter" which would decide about the current value of the search_path.

       

      For instance:

      Database definition:

      CREATE TABLE app1.user_login (

      user_id integer,

      ts timestamp

      );

       

      CREATE TABLE app2.user_login (

      user_id integer,

      ts timestamp

      );

       

      Tableau Custom Query which we use currently:

       

      SELECT user_id, ts::date as dt, 'app1' as app_name, count(*) from app1.user_login GROUP BY 1, 2

      UNION ALL

      SELECT user_id, ts::date as dt, 'app2' as app_name, count(*) from app2.user_login GROUP BY 1, 2

       

      Our preferred way of performing such queries would be:

       

      SET search_path to "[SELECTED_APP]";

      SELECT user_id, ts::date as dt, count(*) from user_login

       

      My question is the following: Is it possible to set the schema that the query has to run on via a parameter or filter within a Tableau dashboard?

       

      Best regards,

      Damian Lilla