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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Getting Direct Reports...
Power Apps
Unanswered

Getting Direct Reports (V2)

(1) ShareShare
ReportReport
Posted on by

Hi,

 

I am quite new to Power Apps and learning on the go. I recently came across Direct reports (v2) using the Office365 property. I am able to get all the DirectReports of the given user. However, this does not satisfy my requirements. What I wanted is to do the following.

Imagine the organization chart are as follows:

A: Managing director
B: Technical director
C: product manager.

Here C reports to B and B reports to A. If I get the directReports of B I will get C. Similarly, If I get the direct reports of A I will get B. However, I want both B and C to be shown if I fetch the direct reports of A.

How can I achieve that using Power Apps?

Thanks in Advance!

Categories:
I have the same question (0)
  • michalparal222 Profile Picture
    86 on at

    Hi @killerBee15 ,

     

    I am no expert too, but I have tried and this was my result, the only limitation is that the number of levels down the structure depends on how many times you copy the part after //  ****Start again**** I did not succeeded to do it in some form of a loop. Anyway it works, so mark my solution, if it is enough for you.

     

    // First set of direct reports
    Set(varResult, Office365Users.DirectReportsV2(TextInputCanvas2.Value));
    ClearCollect(colAllTemp,varResult.value);
    
    // Filter empty rows and first row 
    ClearCollect(colAll, Filter(colAllTemp, !IsBlank(accountEnabled)));
    
    //Get results for first set of direct
    ClearCollect(colAllTemp, ForAll(colAll,Office365Users.DirectReportsV2(ThisRecord.userPrincipalName)));
    ClearCollect(colMergedResults, []); // define new empty collection
    ForAll(colAllTemp,Collect(colMergedResults, ThisRecord.value) );
    
    //Final collection
    Collect(colAll,colMergedResults);
    ClearCollect(colAllFinal, ForAll(Distinct(colAll, ThisRecord), Value)); // Set only uniqe values
    ClearCollect(colAllFinalFiltered, Filter(colAllFinal, !IsBlank(accountEnabled)));
    
    
    // ****Start again**** (third level)
    ClearCollect(colAllTemp, ForAll(colAllFinalFiltered,Office365Users.DirectReportsV2(ThisRecord.userPrincipalName)));
    Clear(colMergedResults);
    ForAll(colAllTemp,Collect(colMergedResults, ThisRecord.value) );
    
    //Final collection
    Collect(colAll,colMergedResults);
    ClearCollect(colAllFinal, ForAll(Distinct(colAll, ThisRecord), Value)); // Set only uniqe values
    ClearCollect(colAllFinalFiltered, Filter(colAllFinal, !IsBlank(accountEnabled)));
    
    // ****Start again**** (fourth level)
    ClearCollect(colAllTemp, ForAll(colAllFinalFiltered,Office365Users.DirectReportsV2(ThisRecord.userPrincipalName)));
    Clear(colMergedResults);
    ForAll(colAllTemp,Collect(colMergedResults, ThisRecord.value) );
    
    //Final collection
    Collect(colAll,colMergedResults);
    ClearCollect(colAllFinal, ForAll(Distinct(colAll, ThisRecord), Value));

     

    This way I counted 1286 users in our org.  🙂

     

    Regards,

    Michal Páral

  • killerBee15 Profile Picture
    on at

    Thank you for your response! I will try this and get back to you.

     

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 541

#2
WarrenBelz Profile Picture

WarrenBelz 434 Most Valuable Professional

#3
Valantis Profile Picture

Valantis 289

Last 30 days Overall leaderboard