4 Replies Latest reply on May 29, 2018 1:05 PM by Monica Van Loon

    Employee Hirarchy

    raj s

      Hi,

       

      I have  columns  employee id,  employee names, mangers names, I need to build a hierarchy in tableau.

       

      Ex

      ---

       

      ABC  -------1 --------c

                          ---------b

       

                        2---------o

                         ---------p

       

                      3 ----------t

                         ----------h

       

       

      I should able to rollup dynamically c---1--abc  same way i can able to drill down---abc--1---c.

       

       

       

      Regards

      Raj

        • 2. Re: Employee Hirarchy
          raj s

          Hi Maneesh,

           

          Challenge is with single column based on manager name I need to build

          hierarchy ..

           

          I need four sub levels..wheather it can be possible in Tableau or at Sql

          level we need to do..?

           

          For example:

           

           

          First I need to know who reporting to manager Raj..

           

          If I got 3 members...then I need to find who are reporting to these 3

          members..then finally I need to create a hierarchy.

           

          Regards

          Raj

           

          On Fri, Feb 9, 2018 at 12:12 PM Maneesh Gaddam <tableaucommunity@tableau.com>

          • 3. Re: Employee Hirarchy
            maneesh.gaddam

            In the single column, I think it isn't possible. On sql side, you should pivot those into the various levels you are looking for and then bring into Tableau to build hierarchy.

            • 4. Re: Employee Hirarchy
              Monica Van Loon

              This is a late reply but I have done this before.  Basically you need to recursively join to the same table one time per level of hierarchy.  So,  join manager id in original table to the employee id.  Then get rid of all redundant columns and call the new employee id (results of the join)  Mgr Level 1 , then do it again and call it Mgr level 2 etc. so you end up with 4 or 5 new columns with a level of  mgr id.  Then in Tableau you can build a hierarchy Mgr Level 5 , Mgr Level 4 etc....  I did this  to secure the data shown by user .  I wanted managers only see their own employees data.  To this end I  built a calculated field called "Is Manager"  which checked if the current logged in user was part of the hierarchy and put it as a data source filter.  This is much better as recursively joining data can be a performance hit unless you filter it right away. You can also do this type of hierarchy in SQL if you are logged into a database.  If you want users to see data only in their own hierarchy by build a dynamic view like the below checking data against logged in user. (in Oracle).

              I wrote a blog and did a webinar on some of this

              https://www.senturus.com/resources/restricting-access-content-user-tableau/

               

               

              Create or replace view My_Employee_Details as select e.employee_id, e.first_name, e.last_name, e.salary, m.Last_name manager_name

              from HR.employees e, HR.employees m

                where e.manager_id = m.employee_id

                and upper(m.LAST_NAME) = user;