Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Unanswered

Worker / employee positions and hierarchy

(1) ShareShare
ReportReport
Posted on by 442
Hello,
I've been tasked to provide an extract of all our employees with their associated position details. I would like to do this through a SQL script for the time being. I have a fairly simply SQL retrieving most of the information I need. The next step would be to show the report-to hierarchy somehow. Which leads me to the questions. Does an OOTB report exists? I know there's a Position hierarchy form available to drill through the hierarchy so hoping there's a companion report or form which would lay it out in a downloadable tabular format. 
  • Guy Terry Profile Picture
    28,693 Super User 2025 Season 1 on at
    Worker / employee positions and hierarchy
    Ah, I thought it might be a one-off exercise. I agree, this is not an excellent long term solution!
     
    I wonder if Power BI has tools to manipulate the data how you would like. I believe it has functionality to handle hierarchies; I just don't know how it works.
  • Guy Terry Profile Picture
    28,693 Super User 2025 Season 1 on at
    Worker / employee positions and hierarchy
    That SQL will give you all positions, and their parent. Considering the data structure, I think you will be doing well to write sql to build the whole hierarchy for you! I suggest some knife and forking in Excel.
  • Navneeth Nagrajan Profile Picture
    1,458 Super User 2025 Season 1 on at
    Worker / employee positions and hierarchy
    Hi,
     
    The SQL Script provided by GuyUK should work but to answer the second part of the question, there is a report called Positions by department report under Human Resources -> Positions section. The Positions by department report gives you the list of positions by department. 
     
    Also, there are some data entities that can be leveraged as mentioned below as an alternative to the SQL Script:
    S. No. Entity Name Target Entity Name
    1.  Position Hierarchies  HcmPositionHierarchyEntity
    2.  Position Hierarchy Type HcmPositionHierarchyTypeEntity
     
    Happy to answer questions, if any.
  • Guy Terry Profile Picture
    28,693 Super User 2025 Season 1 on at
    Worker / employee positions and hierarchy
    If you really want SQL to do it, try this.
     
    DECLARE @Partition bigint
    SELECT @Partition  = Par.RECID FROM dbo.PARTITIONS AS Par WHERE Par.PARTITIONKEY = 'initial'
    
    SELECT P.POSITIONID AS 'Position', PD.DESCRIPTION AS 'Description', PP.POSITIONID AS 'Reports to', PPD.DESCRIPTION AS 'Reports to Description'
    FROM dbo.HCMPOSITION AS P
    INNER JOIN dbo.HCMPOSITIONDETAIL AS PD ON P.PARTITION = PD.PARTITION AND P.RECID = PD.POSITION AND PD.VALIDFROM < GETDATE() AND PD.VALIDTO > GETDATE()
    LEFT JOIN dbo.HCMPOSITIONHIERARCHY AS PH ON P.PARTITION = PH.PARTITION AND P.RECID = PH.POSITION AND PH.VALIDFROM < GETDATE() AND PH.VALIDTO > GETDATE()
    INNER JOIN dbo.HCMPOSITION AS PP ON PH.PARTITION = PP.PARTITION AND PH.PARENTPOSITION = PP.RECID
    INNER JOIN dbo.HCMPOSITIONDETAIL AS PPD ON PP.PARTITION = PPD.PARTITION AND PP.RECID = PPD.POSITION AND PPD.VALIDFROM < GETDATE() AND PPD.VALIDTO > GETDATE()
    WHERE P.PARTITION = @Partition
    ORDER BY P.POSITIONID ASC
     
  • Hana Xue Profile Picture
    Microsoft Employee on at
    Worker / employee positions and hierarchy
    Hi,                          
    You can check if this link is useful.
    Organization hierarchies with standard reports (dynamics.com)
    Best Regards,
    Hana

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,069 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,858 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Product updates

Dynamics 365 release plans