web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Office365Users.DirectR...
Power Apps
Unanswered

Office365Users.DirectReportsV2 Filtering

(1) ShareShare
ReportReport
Posted on by 716 Moderator
I have three dropdowns on the a form.
 
Current Director, Current Manager, Current Prime.
 
First dropdown is populated with a collection named listDirectors. The contents are populated within the OnVisible property of the screen where they're needed.
Second dropdown is populated using a clause I'll share below that needs modifying.
Third dropdown is populated using exactly the same clause as the 2nd but references dropdown 2.
 
As is, it works. But because some of the people returned in the second dropdown do not have direct reports, dropdown 3 errors. Which is just a symptom really.
The problem is that we need to filter the second dropdown to only return users with direct reports themselves.
 
The current clause populating the 2nd dropdown is below. How do I filter this list to only include users with direct reports?
 
Ungroup(
    ForAll(
        Office365Users.DirectReportsV2(drpProposedDirector.Selected.Email).value,
        Table(
            [
                {
                    Claims: "i:0#.f|membership|" & mail,
                    Department: "",
                    DisplayName: displayName,
                    Email: mail,
                    JobTitle: "",
                    Picture: ""
                }
            ]
        )
    ),
    Value
)
Categories:
I have the same question (0)
  • Suggested answer
    Michael E. Gernaey Profile Picture
    53,351 Super User 2025 Season 2 on at
    Hi,
     
    Essentially you need to get a count of the .value.mail (at the end of yours) and if that has 0 do not include them.
     
    So you would probably need to do a ClearCollect first, to populate a collection with their directs.
    If the countrows = 0 do nothing, if it does
    then change your code above to reference the Collection and not the query, that way you aren't querying twice.
     
  • DCHammer Profile Picture
    716 Moderator on at
    Thanks @FLMike. I wish there was a way to reply directly. I realized on the way to the office that just what you said is the likely solution. But even after I built the collection, I didn't know what to filter on. But CountRows make good sense. Now to figure out the syntax.
    Thanks
  • DCHammer Profile Picture
    716 Moderator on at
    If you still see replies to this FLMike, I could still use some help.
     
    I've modified my code to build a collection when the Director is chosen in the first dropdown.
     
    ClearCollect(
            CurrentDirectorSubCollection,
            ForAll(
                Office365Users.DirectReportsV2(Self.Selected.Email).value,
                {
                    Claims: "i:0#.f|membership|" & mail,
                    Department: "",
                    DisplayName: displayName,
                    Email: mail,
                    JobTitle: jobTitle,
                    Picture: ""
                }
            )
        );
    But I cannot figure out how my own how to now figure out which of the people in this collection have Direct reports.
    I understand in theory that I need to loop through the CurrentDirectorSubCollection to see if each row results in a non-zero return when Office365Users.DirectReportsV2 is passed the CurrentDirectorSubCollection.Email but can't write the syntax.
     

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 711 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 319 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard