Forum Discussion
Using Report Meta Data with Power Bi and Power Automate
- Anonymous1 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 MicrosoftPowerBIMgmtRun 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-PowerBIServiceAccount2. 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.
Thankyou for the reply Anonymous !
However, what do I use to call the API. Like what parameters would I be passing to the API? Because this paramter would need to be passed through the Power Automate button that is sitting in Power BI, correct? I want to have a bunch of users be able to implement the button that will print PDFs of their reports, so I need the information to scale dynamically.
Thanks
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.