Get Number of Active Users In a Profile Using SOQL Query

SOQL Query:

SELECT COUNT(Id) FROM User WHERE IsActive = true AND Profile.Name = 'System Administrator' 

Note: Change the Profile Name as per your requirement.

  • pankaj singh

    How to include more profile fields in the query ? When using following query –
    SELECT count(Id), Profile.Name, Profile.PermissionsModifyAllData FROM User GROUP BY Profile.Name

    getting error as – field must be grouped or aggregated : PermissionsModifyAllData

    My requirement is to get maximum fileds of profiles such as – Name, PermissionsModifyAllData, PermissionsViewAllData, PermissionsViewSetup and users count associated with each profile.