6 Replies Latest reply on Sep 12, 2016 12:59 PM by chris.rogeski

    Bug using USERNAME() function and context filter

    Thomas Bergonzini


      I am trying to implement row-level security in our Tableau views following the advice given on this page http://kb.tableausoftware.com/articles/knowledgebase/row-level-security-and-user-filters  (2nd part: Setting Up Automatic User Filters)


      I have 4 Tableau users called A, B, C and D

      In my SQL view i have a Username column that contains A, B, C or D depending on the row.

      In my Tableau view i have a calculated field that does "USERNAME() = Username" and the fiedl is on the filter shelf only including "True" values.

      The Tableau view shows the Username from the SQL view.

      In Tableau Desktop, i log in our Tableau Server so that i can "Filter as User" (bottom right of the screen).

      Everything works fine in Tableau Desktop and Tableau Server in this configuration. Every time i change the Filter as User to A, B, C or D, the rows of my SQL view are filtered correctly.


      Now the problem is if i right click the filter i created and do "Add to Context". In Tableau Desktop, it still works perfectly fine but when i deploy to Tableau Server, the view on Tableau Server starts acting strangely.

      I get the wrong data. For example i log in with username A but i get the data for B.


      If i then click "Refresh data for this view" the correct data is displayed.

      There is apparently a problem of cache when the filter is added to the context. This obviously defeats completely the purpose of implementing row-level security since the wrong data can be shown to the wrong person.


      Thank you