如何从PowerBI公共报告中获取表格名称和报告部分?

huangapple go评论77阅读模式
英文:

How to get the Table name and report section from a PowerBI public report?

问题

I'm looking to build a search feature across multiple public PowerBI published reports. I want to be able to filter, for example, a company name and return all reports that have that company mentioned.

I'm testing the 'Page and Filter on URL' feature. The problem is: I don't know how to find the Table name or the Report Section from a published report. Is that info public?

For this panel, for example: Link, I want to be able to navigate to the first page report view (Relatorio de projetos por tipologia...) and filter for 'Eletropaulo', but I would require the Report Section ID and Table name, which I don't know how to find (or even if I'm able to). The query URL would be something like this:

Query URL

I'd love if someone could tell me if I'm able to gather these parameters, and if Yes, how to do it. Thanks!

英文:

I'm looking to build a search feature across multiple public PowerBI published reports. I want to be able to filter, for example, a company name and return all reports that have that company mentioned.

I'm testing the 'Page and Filter on URL' feature. The problem is: I don't know how to find the Table name or the Report Section from a published report. Is that info public?

For this panel, for example: https://app.powerbi.com/view?r=eyJrIjoiNGI1OGYwOTgtZWQ5YS00Y2I4LTlkOTUtNjI4MDE1Yjk4MjE1IiwidCI6IjQwZDZmOWI4LWVjYTctNDZhMi05MmQ0LWVhNGU5YzAxNzBlMSIsImMiOjR9

I want to be able to navigate to the first page report view (Relatorio de projetos por tipologia...) and filter for 'Eletropaulo', but I would require the Report Section ID and Table name, which I don't know how to find (of even if I'm able to). The query URL would be something like this:

https://app.powerbi.com/view?r=eyJrIjoiNGI1OGYwOTgtZWQ5YS00Y2I4LTlkOTUtNjI4MDE1Yjk4MjE1IiwidCI6IjQwZDZmOWI4LWVjYTctNDZhMi05MmQ0LWVhNGU5YzAxNzBlMSIsImMiOjR9&pageName=ReportSectionID&filter=TableName/Sigla='Eletropaulo'

I'd love if someone could tell me if I'm able to gather these parameters, and if Yes, how to do it. Thanks!

答案1

得分: 1

以下是您要翻译的内容:

让我向您解释一下这里的情况:关于报告部分 ID 和表名称的信息无法从发布的 Power BI 报告中公开访问。这些细节未通过 Power BI 服务或报告 URL 公开。

关于 Power BI 中的“页面和URL上的筛选器”功能 允许您通过 URL 中的查询参数指定报告页面并应用筛选器,但需要您知道报告页面的名称以及表中的字段名称。

您可以使用 Power BI REST API 与报告进行编程交互并检索所需的信息。使用 API,您将能够访问报告的元数据,包括报告部分、表和字段。

首先,在 Azure Active Directory 中注册一个应用程序,以获取访问 Power BI API 所需的凭据:API 认证的客户端 ID 和客户端密钥。

然后,使用 Power BI REST API 进行身份验证:尝试通过向 Azure AD 令牌端点发出 POST 请求,使用您的客户端 ID、客户端密钥和其他必需参数来获取访问令牌。

使用获取的访问令牌,向 Power BI REST API 的“获取报告”端点(https://api.powerbi.com/v1.0/myorg/reports)发出 GET 请求。您需要解析响应以提取报告的 ID 和名称。

对于每个报告,向“获取组中的报告”端点(https://api.powerbi.com/v1.0/myorg/groups/{group_id}/reports/{report_id})发出 GET 请求,以检索报告的元数据。您需要从响应中提取报告部分、表和它们相应的字段。

现在您拥有一切来实现搜索功能:

  • 遍历检索到的报告、部分和表。
  • 对于每个表,构建一个包含所需筛选条件(例如,CompanyName = 'Eletropaulo')的 DAX 查询。
  • 使用“执行 DAX 查询”端点(https://api.powerbi.com/v1.0/myorg/groups/{group_id}/reports/{report_id}/models/{model_id}/queries)执行 DAX 查询,并将 DAX 查询作为请求正文传递。
  • 解析响应以检索筛选的数据。

如果您需要了解有关 Power BI REST API 的更多信息,请查看文档:https://docs.microsoft.com/en-us/rest/api/power-bi/

英文:

Let me explain to you the situation here: the information about the Report Section ID and Table name is not publicly accessible from the published Power BI reports. These details are not exposed through the Power BI service or the report URL.

Regarding the 'Page and Filter on URL' feature in Power BI allows you to specify the report page and apply filters using query parameters in the URL, but it requires you to know the names of the report pages and the fields within the tables.

You can use the Power BI REST API to programmatically interact with the reports and retrieve the necessary information

. Using the API, you will be able to access the report metadata, including the report sections, tables, and fields.

Begin with registering an application in Azure Active Directory to obtain the necessary credentials for accessing the Power BI API : client ID and client secret for API authentication.

Then authenticate with the Power BI REST API: try to obtain an access token by making a POST request to the Azure AD token endpoint using your client ID, client secret, and other required parameters.

Make a GET request to the Power BI REST API's Get Reports endpoint (https://api.powerbi.com/v1.0/myorg/reports) using the obtained access token.
You need to parse the response to extract the necessary information such as the report IDs and names.

For each report, make a GET request to the Get Report In Group endpoint (https://api.powerbi.com/v1.0/myorg/groups/{group_id}/reports/{report_id}) to retrieve the report metadata. You need to extract the report sections, tables, and their corresponding fields from the response.

Now you have everything to implement the search functionality:

  • Iterate through the retrieved reports, sections, and tables.
  • For each table, construct a DAX query that includes the desired filter condition (e.g., CompanyName = 'Eletropaulo').
  • Execute the DAX query using the Execute DAX Query endpoint (https://api.powerbi.com/v1.0/myorg/groups/{group_id}/reports/{report_id}/models/{model_id}/queries) and pass the DAX query as the request body.
  • Parse the response to retrieve the filtered data.

Check the documentation if you need to know more about Power BI REST API: https://docs.microsoft.com/en-us/rest/api/power-bi/

huangapple
  • 本文由 发表于 2023年6月26日 22:51:55
  • 转载请务必保留本文链接:https://go.coder-hub.com/76557819.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定