Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Answered

Using a collection to hold direct reports

(0) ShareShare
ReportReport
Posted on by 714 Super User 2025 Season 1

So I have a really simple ClearCollect statement:

 

ClearCollect(colTechTeam, Office365Users.DirectReportsV2("someone@somewhere.com"))

 

This works a treat. But, for the life of me, I cannot determine how to now query against the contents of the collection.

When I look at it in the Editor, I see this:

DCHammer_0-1714412008392.png

I expected to see the table of users right there. But they're buried under that value, here:

DCHammer_1-1714412073138.png

What you're seeing is the first X columns in the Claims record for each user returned. I didn't bother showing all and left out the actual data.

In that data of course, is a 'mail' column. I want to compare values in that column to the current user but can't figure out how.

I was trying to use the below to create a filtered collection which will have 1 or 0 records depending on result.

 

ClearCollect(
 colFilteredTechTeam,
 Filter(colTechTeam, mail = varCurrentUserEmail)
)

 

But mail is not a valid column name in the colTechTeam collection.

Categories:
  • DCHammer Profile Picture
    714 Super User 2025 Season 1 on at
    Re: Using a collection to hold direct reports

    Homerun. Thanks my semi-anonymous friend.

  • Verified answer
    Gochix Profile Picture
    1,933 Super User 2025 Season 1 on at
    Re: Using a collection to hold direct reports

    @DCHammer ,

    If this solution is working for you:

    ClearCollect(colTechTeam, Filter(Office365Users.DirectReportsV2("someone@somewhere.com").value,mail=varCurrentUserEmail))

    then for the visibility property you need only:

    If(varCurrentUser in colTechTeam.mail,true)


    _____________________________________________________________________________________
    Please give a thumbs up if I resolved your issue! Please click Accept as Solution to close the topic!

  • DCHammer Profile Picture
    714 Super User 2025 Season 1 on at
    Re: Using a collection to hold direct reports

    I think that's going to work actually but I'm not entirely sure what I'll compare on the visibility property.

    I think what's right is to compare varCurrentUserEmail to colFilteredTechTeam obviously but to .value, .email? Maybe I can just use trial and error with an end user.

     

    I also tried using the same filter condition you used to populate the second collection for visibility but I cannot figure out the syntax.

  • DCHammer Profile Picture
    714 Super User 2025 Season 1 on at
    Re: Using a collection to hold direct reports

    That seems logical and shows no error but when executed doesn't populate anything in the collection at all.

  • Gochix Profile Picture
    1,933 Super User 2025 Season 1 on at
    Re: Using a collection to hold direct reports

    @DCHammer ,

     

    I've updated my solution so have a look if that works better for you.
    _____________________________________________________________________________________
    Please give a thumbs up if I resolved your issue! Please click Accept as Solution to close the topic!

  • DCHammer Profile Picture
    714 Super User 2025 Season 1 on at
    Re: Using a collection to hold direct reports

    So I'm at least partway there since the following works:

    ClearCollect(
     colFilteredTechTeam,
     Filter(colTechTeam, varCurrentUserEmail in value.mail)
    )

     

    I'm having a little challenge testing because I'm not in the first collection so running OnStart results in colTechTeam populating correctly but the colFilteredTechTeam ends up empty. I'm going to assume it's going to build a collection that looks exactly like the first with only one row buried under 'value'.

     

    So I thought this would work on Visible property but doesn't:

    If(varCurrentUserEmail in colFilteredTechTeam.value.mail, true,false)

    I also tried this thinking I could grab the First row since there will only be one based on the way the collection is populated.

    If(varCurrentUserEmail = First(colFilteredTechTeam).value.mail, true,false)

    But even though I'm specifying a specific record and field for the comparison, PA still tells me I can't compare text and a table.

     

    Also, if anyone has a better suggestion I'm all ears.

    I'm just trying to hide some datacards and controls for everyone expect users that report to a specific manager.

     

  • Gochix Profile Picture
    1,933 Super User 2025 Season 1 on at
    Re: Using a collection to hold direct reports

    @DCHammer ,

     

     

    ClearCollect(
     colFilteredTechTeam,
     Filter(Ungroup(colTechTeam,value),mail=varCurrentUserEmail))

     

     

    or do everything in one collection:

     

    ClearCollect(colTechTeam, Filter(Office365Users.DirectReportsV2("someone@somewhere.com").value,mail=varCurrentUserEmail))

     


    _____________________________________________________________________________________
    Please give a thumbs up if I resolved your issue! Please click Accept as Solution to close the topic!

  • BhaskarDhone Profile Picture
    790 Super User 2025 Season 1 on at
    Re: Using a collection to hold direct reports

    Try this

    ClearCollect(colTechTeam, Office365Users.DirectReportsV2("someone@somewhere.com").value)

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,524 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,906 Most Valuable Professional

Leaderboard