Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
AdrianChang
Frequent Visitor

How can I get the supervisor from office 365?

I have a SharePoint list with a person field. And I would like to get the supervisor of this person field in Power BI.
How can I do it? I cannot find Office 365 in "Get Data".

3 ACCEPTED SOLUTIONS
Shravan133
Solution Sage
Solution Sage

To get the supervisor of a person field from a SharePoint list in Power BI, you can use the Microsoft Graph API to fetch the user's manager information from Office 365. Here's how you can achieve this:

Steps to Get Supervisor Data

  1. Get Data from SharePoint Online List:

    • Go to Power BI Desktop.
    • Click on Get Data.
    • Choose SharePoint Online List.
    • Enter the URL of your SharePoint site and connect to the list containing the person field.
  2. Fetch Supervisor Data using Microsoft Graph API:

    • To get the supervisor (manager) information, you will need to access the Microsoft Graph API. This involves setting up an app registration in Azure AD to get the necessary permissions.
  3. Register an Application in Azure AD:

    • Go to the Azure portal and navigate to Azure Active Directory.
    • Click on App registrations and then New registration.
    • Enter a name for your application and follow the prompts to register it.
    • Once registered, note down the Application (client) ID and Directory (tenant) ID.
    • Go to Certificates & secrets and create a new client secret. Note down the secret value.
  4. Grant API Permissions:

    • In the app registration, go to API permissions.
    • Click on Add a permission > Microsoft Graph > Delegated permissions.
    • Add the permission User.Read.All and User.ReadBasic.All.
    • You might need to grant admin consent for these permissions.
  5. Fetch Data in Power BI Using Power Query:

    • Open Power BI Desktop and go to Home > Transform Data.
    • In the Power Query Editor, use the following M code to make a request to the Microsoft Graph API:
 

let
clientId = "your_client_id",
clientSecret = "your_client_secret",
tenantId = "your_tenant_id",
resource = "https://graph.microsoft.com/",
authority = "https://login.microsoftonline.com/" & tenantId & "/oauth2/v2.0/token",
body = "client_id=" & clientId & "&scope=" & Uri.EscapeDataString(resource & ".default") & "&client_secret=" & Uri.EscapeDataString(clientSecret) & "&grant_type=client_credentials",
authResponse = Json.Document(Web.Contents(authority, [Content=Text.ToBinary(body), Headers=[#"Content-Type"="application/x-www-form-urlencoded"]])),
accessToken = authResponse[access_token],

// Replace 'userPrincipalName' with the actual user field you are querying
userPrincipalName = "user@example.com",
managerUrl = "https://graph.microsoft.com/v1.0/users/" & userPrincipalName & "/manager",
managerResponse = Json.Document(Web.Contents(managerUrl, [Headers=[Authorization="Bearer " & accessToken]])),
managerName = managerResponse[displayName]
in
managerName

  1. Combine Data:
    • Combine the SharePoint data and the manager data in Power BI.
    • You can use Power Query to merge the SharePoint list with the supervisor information fetched from Microsoft Graph API.

This approach will allow you to get the supervisor information of a person field from a SharePoint list in Power BI.

Alternative Approach Using Power Automate

If you prefer using Power Automate to fetch and store the supervisor information, you can create a flow to get the manager of a user and store it in the SharePoint list:

  1. Create a Flow in Power Automate:

    • Trigger the flow on item creation or modification in the SharePoint list.
    • Use the "Get user profile (V2)" action to fetch the user's profile using their email or user principal name.
    • Use the "Get manager (V2)" action to get the manager information.
    • Update the SharePoint list with the manager's information.
  2. Use the Updated SharePoint List in Power BI:

    • Once the SharePoint list contains the supervisor information, you can directly import the updated list into Power BI.

By using either of these methods, you can effectively retrieve and display supervisor information in Power BI

View solution in original post

amitchandak
Super User
Super User

@AdrianChang , do you have supervisor information in Office 365, usually it should be there in your ERP

of if you have configured it in Exchange : https://learn.microsoft.com/en-us/exchange/address-books/hierarchical-address-books/hierarchical-add...

 

Also, check if you can connect to the exchange using the active directory connector

https://community.fabric.microsoft.com/t5/Desktop/Email-Address-Book/td-p/2401882

 

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

View solution in original post

christinepayton
Super User
Super User

There are a slew of profile fields available in the SharePoint Online list connector, primarily the 1.0 version, but I don't think manager is one of them. You can expand things like job title, department, email, name, and other things there though with the expandy arrow next to the field (it'll be one of the ones on the far right that has a different icon than the text fields). 

View solution in original post

3 REPLIES 3
christinepayton
Super User
Super User

There are a slew of profile fields available in the SharePoint Online list connector, primarily the 1.0 version, but I don't think manager is one of them. You can expand things like job title, department, email, name, and other things there though with the expandy arrow next to the field (it'll be one of the ones on the far right that has a different icon than the text fields). 

amitchandak
Super User
Super User

@AdrianChang , do you have supervisor information in Office 365, usually it should be there in your ERP

of if you have configured it in Exchange : https://learn.microsoft.com/en-us/exchange/address-books/hierarchical-address-books/hierarchical-add...

 

Also, check if you can connect to the exchange using the active directory connector

https://community.fabric.microsoft.com/t5/Desktop/Email-Address-Book/td-p/2401882

 

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here
Shravan133
Solution Sage
Solution Sage

To get the supervisor of a person field from a SharePoint list in Power BI, you can use the Microsoft Graph API to fetch the user's manager information from Office 365. Here's how you can achieve this:

Steps to Get Supervisor Data

  1. Get Data from SharePoint Online List:

    • Go to Power BI Desktop.
    • Click on Get Data.
    • Choose SharePoint Online List.
    • Enter the URL of your SharePoint site and connect to the list containing the person field.
  2. Fetch Supervisor Data using Microsoft Graph API:

    • To get the supervisor (manager) information, you will need to access the Microsoft Graph API. This involves setting up an app registration in Azure AD to get the necessary permissions.
  3. Register an Application in Azure AD:

    • Go to the Azure portal and navigate to Azure Active Directory.
    • Click on App registrations and then New registration.
    • Enter a name for your application and follow the prompts to register it.
    • Once registered, note down the Application (client) ID and Directory (tenant) ID.
    • Go to Certificates & secrets and create a new client secret. Note down the secret value.
  4. Grant API Permissions:

    • In the app registration, go to API permissions.
    • Click on Add a permission > Microsoft Graph > Delegated permissions.
    • Add the permission User.Read.All and User.ReadBasic.All.
    • You might need to grant admin consent for these permissions.
  5. Fetch Data in Power BI Using Power Query:

    • Open Power BI Desktop and go to Home > Transform Data.
    • In the Power Query Editor, use the following M code to make a request to the Microsoft Graph API:
 

let
clientId = "your_client_id",
clientSecret = "your_client_secret",
tenantId = "your_tenant_id",
resource = "https://graph.microsoft.com/",
authority = "https://login.microsoftonline.com/" & tenantId & "/oauth2/v2.0/token",
body = "client_id=" & clientId & "&scope=" & Uri.EscapeDataString(resource & ".default") & "&client_secret=" & Uri.EscapeDataString(clientSecret) & "&grant_type=client_credentials",
authResponse = Json.Document(Web.Contents(authority, [Content=Text.ToBinary(body), Headers=[#"Content-Type"="application/x-www-form-urlencoded"]])),
accessToken = authResponse[access_token],

// Replace 'userPrincipalName' with the actual user field you are querying
userPrincipalName = "user@example.com",
managerUrl = "https://graph.microsoft.com/v1.0/users/" & userPrincipalName & "/manager",
managerResponse = Json.Document(Web.Contents(managerUrl, [Headers=[Authorization="Bearer " & accessToken]])),
managerName = managerResponse[displayName]
in
managerName

  1. Combine Data:
    • Combine the SharePoint data and the manager data in Power BI.
    • You can use Power Query to merge the SharePoint list with the supervisor information fetched from Microsoft Graph API.

This approach will allow you to get the supervisor information of a person field from a SharePoint list in Power BI.

Alternative Approach Using Power Automate

If you prefer using Power Automate to fetch and store the supervisor information, you can create a flow to get the manager of a user and store it in the SharePoint list:

  1. Create a Flow in Power Automate:

    • Trigger the flow on item creation or modification in the SharePoint list.
    • Use the "Get user profile (V2)" action to fetch the user's profile using their email or user principal name.
    • Use the "Get manager (V2)" action to get the manager information.
    • Update the SharePoint list with the manager's information.
  2. Use the Updated SharePoint List in Power BI:

    • Once the SharePoint list contains the supervisor information, you can directly import the updated list into Power BI.

By using either of these methods, you can effectively retrieve and display supervisor information in Power BI

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.