๐ฅ Recipe ยท User & Group Management
Generate a Department Headcount Report via Microsoft Graph
Query Entra ID to produce a sorted breakdown of users per department across your tenant
Complexity
Beginner
Impact
read-only + reporting + low-risk
Context
Why This Matters
Department headcount reports are a foundational HR and IT operations artifact. They're useful for license planning, org chart validation, onboarding capacity planning, identifying users with missing or malformed department attributes, and reconciling Entra ID data with HRIS systems like Workday or BambooHR.
Because the department property is a free-text field on the Entra user object, this report is also a quick way to surface data hygiene issues โ typos, inconsistent casing, or users whose department was never populated at all.
When to run it
- Monthly, as part of an identity hygiene review
- Before a reorg or cost-center realignment
- Whenever HR asks "how many people are in X?" and you want a definitive answer from the source of truth
- Before bulk license assignments scoped by department
Expected Outcomes
After running this recipe you will have:
- A sorted list of every distinct
departmentvalue in Entra ID and the count of users in each - A count of users with no department assigned (reported as (Unassigned))
- A total user count for the tenant
- Optional CSV output suitable for sharing with HR or importing into Excel/Power BI
Risks & Considerations
Things to watch for
- Free-text inconsistency. "Engineering", "engineering", and "Eng" will be counted as three separate departments. Consider normalizing before reporting.
- Guest and service accounts. The default query returns all users including guests and non-human accounts. Filter by
userType eq 'Member'andaccountEnabled eq trueif you only want active employees. - Pagination. Tenants with more than ~100 users will paginate. Always follow
@odata.nextLinkto avoid under-reporting. - Privacy. While headcount totals are generally non-sensitive, some orgs treat department-level staffing data as confidential. Handle the output accordingly.
- Do not use this report as authoritative headcount for finance or legal purposes without reconciling against HRIS โ Entra is only as accurate as the provisioning process that populates it.
Required Permissions
| Permission | Why It's Needed |
|---|---|
| User.Read.All | Required to enumerate all users in the tenant and read the department property |
| Directory.Read.All | Alternative broader permission that also grants read access to user attributes |
The fastest way to get this done โ just ask Dex. Copy the prompt below and paste it into your Dex conversation.
For IT Admins
Paste into Dex CoAdmin