Count User Logins This Week by License Type in Salesforce

Using `Profile.UserLicense.LicenseDefinitionKey` we can select users by license type

me@jaykilleen.com wrote this about 3 years ago and it was last updated about 3 years ago.


← Back to the Posts

A simple SOQL query to return a count of all users that have logged into Salesforce THIS WEEK based on having a full salesforce license.

If you need to query by other license types you should check the table UserLicence for the different licences your system has available, then using those values instead of SFDC to determine if they are being used/logged in.

Select 
  COUNT(Id)
From 
  User
WHERE
  IsActive = true AND
  LastLoginDate = THIS_WEEK AND
  Profile.UserLicense.LicenseDefinitionKey = 'SFDC'