3 Replies Latest reply on Sep 10, 2018 1:50 PM by Alexander Dawson

    Dynamic filter

    Fernando Abrão

      Hello all,

       

      Is that possible to use a filter from database (datasource) ? I have one dashboard that I associate user from Tableau with an id to filter values. Is that possible doing this from database informations?

       

      Regards,

        • 1. Re: Dynamic filter
          Alexander Dawson

          Did you check the User group of functions?  If your external database's user id matches the id in Tableau then you could do something like: 

           

          USERNAME()  =  [externalid]  

           

          Then just filter for that calculation to be true.  Unfortunately many cases the Id's won't match but I'm hoping you can find a way to map them over.

          • 2. Re: Dynamic filter
            Fernando Abrão

            Hello Alexander,

             

             

            Thank you for your help.

            So, if I want to do something like having Datasource as SQL:

            "SELECT INFORMATION FROM TABLE_DATA WHERE ID IN (SELECT CURRENT_ID FROM USER_TABLE WHERE USERNAME = USERNAME())" is that correct?

             

            Regards,

            Fernando

            • 3. Re: Dynamic filter
              Alexander Dawson

              It shouldn't need any custom SQL.  Assuming the ID's are the same.

              1)  Initially build the report so all rows for all users are visible. 

              2)  Create a calculated field using the USERNAME() function.  Something like Username() = [databasesusername]  <--I'm not sure what your database's column is called.

              3)  Create a filter on 2) so that it only displays TRUE.