I’m looking to create a list of all the users in our company (roughly 1200 users) and display a grouped list of all the departments with the count of users in each department (see below). I managed to create this, but because I’m using the searchusersV2 function, it only displays the first 999 employees.

Sort(
GroupBy(
Filter(Office365Users.SearchUserV2({isSearchTermRequired: "No", top:999}).value,Len(Department)>0)
,"Department","Grouped")
,Department)
To get around the 999 max users I tried the following with no luck:
SearchUsersV2 function as shown above
AzureAD.GetGroupMembers formula
I tried combining the 3 & 4 using addcollumns and the lookup function, but it didn’t return all users' department information
Sort(AddColumns(
AzureAD.GetGroupMembers("81d80d8b-e7af-4aad-8752-ab5546bf7b3f",{'$top': 999}).value,
"User Name",displayName,
"Department Details",
LookUp(
Office365Users.SearchUserV2({isSearchTermRequired:"No", top:999}).value,mail = Mail,Department)
),displayName)
4. Export to a SharePoint list via Power Automate.