Forum Discussion

alexkarwoski's avatar
alexkarwoski
Frequent Visitor
1 year ago
Solved

Using Report Meta Data with Power Bi and Power Automate

I need to pass the Report Name or report ID to the power automate flow linked through a button sitting on the power BI report. Is this possible? I want to make a flow that works across reports, becau...
  • Anonymous's avatar
    Anonymous
    1 year ago

    Hi alexkarwoski 

     

    Sorry for late.

    There was a slight misunderstanding in the previous reply. I think you want to pass the report ID/name of the report in the workspace into flow as a field in the Power Automate visual.

     

    Please try the following steps:

    1. Getting report information in the workspace via PowerShell

    Run PowerShell ISE as administrator and use the following command to install the Power BI module:

    Install-Module -Name MicrosoftPowerBIMgmt

    Run the following script to get the report information and save it into a csv file:

    Connect-PowerBIServiceAccount
    $Workspaces = Get-PowerBIWorkspace -All
    $Reports = @()
    ForEach ($workspace in $Workspaces) {
        Write-Host $workspace.Name
        $workspaceReports = Get-PowerBIReport -WorkspaceId $workspace.Id
        ForEach ($report in $workspaceReports) {
            $reportInfo = [pscustomobject]@{
                WorkspaceName = $workspace.Name
                WorkspaceID = $workspace.Id
                ReportName = $report.Name
                ReportID = $report.Id
            }
            $Reports += $reportInfo
        }
    }
    $Dir = "C:\Users\YourPCUserName\Desktop\Reports.csv"
    $Reports | Export-Csv $Dir -NoTypeInformation -Encoding UTF8
    Disconnect-PowerBIServiceAccount

     

     2. Import the csv file into your Power BI report, create Power Automate visual in the report, drag the WorkspaceID, ReportID, ReportName fields from the csv file into the visual.

    Click on the visual ellipsis and select Edit, choose existing flow or create a new flow, the flow is as follows:

    On Power BI button clicked -> Export to File for Power BI Reports -> Create file

    In the “Export To File for Power BI Report” action, drag and drop WorkspaceID, ReportID into it.

    In the “Create file” action, fill in the information about the SharePoint site, use the content returned from the “Export To File for Power BI Report” action as the “File Content”, and use the following expression as the “File Name”:

    concat(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(items('Apply_to_each')?['ReportName'], '#', ''), '%', ''), '*', ''), ':', ''), '<', ''), '>', ''), '?', ''), '/', ''), '|', ''), ' ', '_'), '_', utcNow(), '.pdf')

     

    3. Select Save and Apply, then back to the report and click the button to run flow.

     

     

    Best Regards,
    Jarvis Tang
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.