Forum Discussion

Jerome_C63's avatar
Jerome_C63
Frequent Visitor
1 year ago
Solved

Power BI and Intune MobileApps

Hi everyone,

I'm in the process of creating a dashboard for applications managed by Intune via MS Graph.

Attached is my command to retrieve the id, displayname and assignments.

// Step 2 : Query MS Graph URL
Source = OData.Feed(“https://graph.microsoft.com/v1.0/deviceAppManagement/mobileApps?$select=id,displayName,assignments,categories”, [ Authorization = “Bearer ‘ & access_token ], [ ExcludedFromCacheKey = {’Authorization”}, ODataVersion = 4, Implementation = “2.0” ]),

#“Renamed Columns” = Table.RenameColumns(Source,{{“id”, “Appsid”}})
in
#Renamed Columns


I get my 4 columns with a “Table” for the values for “assignments” and “categories”.
When I click on a “Table” to see the values linked to an application, I get a nice error message.

In my opinion, Power BI uses the wrong URL Url=https://graph.microsoft.com/v1.0/deviceAppManagement/mobileApps('4e7d39d6-4466-4636-89e3-1172ff691357')/microsoft.graph.win32LobApp/assignments because when I run the following query I get the result I want by doing some transformation afterwards.

 

    #“Apps with Assignments” = Table.AddColumn(Source, “Assignments”, each 
        let 
            appId = [id],
            assignments = try OData.Feed(“https://graph.microsoft.com/v1.0/deviceAppManagement/mobileApps/” & appId & “/assignments”, 
                [ Authorization = “Bearer ” & access_token ], 
                [ ExcludedFromCacheKey = {“Authorization”}, ODataVersion = 4, Implementation = “2.0” ])
        in 
            assignments
    ),

 

The problem with doing it this way is that I launch as many requests as there are applications and this has an impact on data retrieval time.

 

Do you have a better solution for retrieving information from “Tables” without having to relaunch an application-specific MS Graph query in Power Bi?



Thank you in advance for your ideas



  • Hello Anonymous 

     

    I tried your solution but it didn't work. I was able to find a solution on my own and this is how I managed it.


    // Step 1 : Get Token
    resource = "https://graph.microsoft.com",
    tokenResponse = Json.Document(Web.Contents("https://login.windows.net/",
    [
    RelativePath = #"Azure AD Tenant ID" & "/oauth2/token",
    Content = Text.ToBinary(Uri.BuildQueryString(
    [
    client_id = #"Azure Application Client ID",
    resource = resource,
    grant_type = "client_credentials",
    client_secret = #"Azure Application Client Secret"
    ]
    )),
    Headers = [Accept = "application/json"], ManualStatusHandling = {400}
    ])),
    access_token = tokenResponse[access_token],

    // Step 2 : Query MS Graph URL
    SourceAssignmentApps = Web.Contents("https://graph.microsoft.com/beta/deviceAppManagement/mobileApps?$select=id&$expand=assignments",[ Headers = [ Authorization = "Bearer " & access_token, Accept = "application/json" ] ]),

    // Handle json to retrieve values
    parsedJsonAssignmentApps = Json.Document(SourceAssignmentApps),
    metadataAssignmentApps = Record.ToTable(parsedJsonAssignmentApps),
    ValueAssignmentApps = metadataAssignmentApps{2}[Value],

    I hope this helps others.

    Have a nice day

6 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Jerome_C63,

     

    Sure! Here's a rephrased version of your message:


    Thanks for sharing the solution! If you could kindly mark your response as the "Accepted Solution", it would really help others in the community who might face a similar issue. It’ll make it easier for them to find the answer quickly.

     

    Thanks & regards,

    Prasanna Kumar

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hell0 Jerome_C63 

    Thank you for reaching out to the Microsoft Fabric Forum Community.

     

    Use $expand=assignments,categories in the Graph API URL to include navigation property data in a single request.

    Use Table.ExpandTableColumn after expansion to flatten nested data for reporting.

    Combine $select and $expand like this:

    // Step 1: Query MS Graph API with $expand
    Source = OData.Feed("https://graph.microsoft.com/v1.0/deviceAppManagement/mobileApps?$select=id,displayName&$expand=assignments,categories",
    [Authorization = "Bearer " & access_token, ExcludedFromCacheKey = {"Authorization"}, ODataVersion = 4, Implementation = "2.0"]),

    // Step 2: Expand Assignments and Categories
    ExpandedAssignments = Table.ExpandTableColumn(Source, "assignments", {"id", "target", "intent"}, {"AssignmentId", "Target", "Intent"}),
    ExpandedCategories = Table.ExpandTableColumn(ExpandedAssignments, "categories", {"id", "displayName"}, {"CategoryId", "CategoryName"}),

    // Step 3: Rename Columns
    RenamedColumns = Table.RenameColumns(ExpandedCategories, {{"id", "Appsid"}})
    in
    RenamedColumns


    If this information is helpful, please “Accept it as a solution” and give a "kudos" to assist other community members in resolving similar issues more efficiently.
    Thank you.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Jerome_C63,

     

    As we haven’t heard back from you, we wanted to kindly follow up to check if the solution provided for the issue worked? or Let us know if you need any further assistance?
    If our response addressed, please mark it as Accept as solution and click Yes if you found it helpful.

     

    Regards,
    Prasanna Kumar

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Jerome_C63,

     

    we wanted to kindly follow up to check if the solution provided for the issue worked? or Let us know if you need any further assistance?

    If our response addressed, please mark it as Accept as solution and click Yes if you found it helpful.

     

    Regards,

    Prasanna Kumar

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Jerome_C63,

    Just a gentle reminder — has your issue been resolved? If so, we’d be grateful if you could mark the solution that worked as Accepted Solution, or feel free to share your own if you found a different fix.

    This not only closes the loop on your query but also helps others in the community solve similar issues faster.

    Thank you for your time and feedback!

     

    Best,

    Prasanna Kumar

  • Jerome_C63's avatar
    Jerome_C63
    Frequent Visitor

    Hello Anonymous 

     

    I tried your solution but it didn't work. I was able to find a solution on my own and this is how I managed it.


    // Step 1 : Get Token
    resource = "https://graph.microsoft.com",
    tokenResponse = Json.Document(Web.Contents("https://login.windows.net/",
    [
    RelativePath = #"Azure AD Tenant ID" & "/oauth2/token",
    Content = Text.ToBinary(Uri.BuildQueryString(
    [
    client_id = #"Azure Application Client ID",
    resource = resource,
    grant_type = "client_credentials",
    client_secret = #"Azure Application Client Secret"
    ]
    )),
    Headers = [Accept = "application/json"], ManualStatusHandling = {400}
    ])),
    access_token = tokenResponse[access_token],

    // Step 2 : Query MS Graph URL
    SourceAssignmentApps = Web.Contents("https://graph.microsoft.com/beta/deviceAppManagement/mobileApps?$select=id&$expand=assignments",[ Headers = [ Authorization = "Bearer " & access_token, Accept = "application/json" ] ]),

    // Handle json to retrieve values
    parsedJsonAssignmentApps = Json.Document(SourceAssignmentApps),
    metadataAssignmentApps = Record.ToTable(parsedJsonAssignmentApps),
    ValueAssignmentApps = metadataAssignmentApps{2}[Value],

    I hope this helps others.

    Have a nice day