4 Replies Latest reply on Aug 9, 2018 3:33 AM by Paulo Dantas

    Substitute one username() for another

    Yuriy Ovchinnikov

      Hi guys!


      I have 2 groups of employees: subordinates and managers.

      When I apply username() function all see relevant info: subordinate sees her/his data, manager her/his team data.

      Now I need to enable employee to see his peer data. Effectively substituting subordinate account for managers account.


      I tried simple calculation: IF USERNAME()=[emp_account] then [manager_account] END

      But it returns the very same as simple USERNAME()


      Please help!


      Thank you,

        • 1. Re: Substitute one username() for another
          Mark Fraser

          Hi Yuriy


          Are you aware of what the USERNAME() function will provide you? The function - Returns the username for the current user. This is the Tableau Server or Tableau Online username when the user is signed in; otherwise it is the local or network username for the Tableau Desktop user.


          You may find that the format/content of USERNAME is not what you expect - its worth testing that first

          For example, mine returns my full email address not my login


          Here are some other user related functions - these maybe helpful

          User Functions




          1 of 1 people found this helpful
          • 2. Re: Substitute one username() for another
            Yuriy Ovchinnikov

            Hi Mark!


            Sorry for not been clear. by applying the following function USERNAME()=[emp_account] and dragging it to filter field and set values to 'TRUE' I got dynamic filtering by emp_account.

            By applying  IF USERNAME()=[emp_account] then [manager_account] END I wanted to substitute emp_account by manager_account. But I ended up with the very same result.

            What I wanted Tableau to do is to dynamically filter by employee manager and enable an employee to see his peers data not only his own.

            Hopefully, it became more apparent now.



            • 3. Re: Substitute one username() for another
              Paulo Dantas

              Hi Yuriy,


              perhaps for you are connected with your user you will get this information TRUE if you are employee and manager.


              Where you get this information?



              • 4. Re: Substitute one username() for another
                Yuriy Ovchinnikov

                In my data source I have:

                A) employee column (subordinate)

                B) manager column (upper level to A)

                C) measure column


                Based on that I created worksheets/dashboards.

                Then I created calculated field: USERNAME()=[emp_account] and drag it to filters on each sheet and set value to 'TRUE' and finally published it to tableau server.

                Now each employee of group (A) observers his measure values (C), which is dynamically filtered based on username coming in.


                Now I want dynamic filter to be based on employee's manager.

                Process: An employee of group (A) got into the dashboard and sees data relevant to him and his peers (subordinates of his manager). all measure values related to subordinates of his manager.