表中的超链接Hyperlinks in tables

本主题介绍如何使用 Power BI Desktop 创建超链接。This topic teaches you how to use Power BI Desktop to create hyperlinks. 创建后,使用 Desktop 或 Power BI 服务将这些超链接添加到你的报表表格和矩形图。Then, once created, use either Desktop or Power BI service to add those hyperlinks to your report tables and matrixes.

注意仪表板上的磁贴仪表板上的文本框中的超链接可使用 Power BI 服务实时创建。NOTE: Hyperlinks in tiles on dashboards and text boxes on dashboards can be created on-the-fly using Power BI service. 报表中的文本框中的超链接可以使用 Power BI 服务和 Power BI Desktop 实时创建。Hyperlinks in text boxes in reports can be created on-the-fly using Power BI service and Power BI Desktop.

可在 Power BI Desktop 中创建表和矩形图中的超链接,但不能从 Power BI 服务进行此操作。Hyperlinks in tables and matrixes can be created in Power BI Desktop, but not from Power BI Service. 在将工作簿导入到 Power BI 之前,还可以在 Excel Power Pivot 中创建超链接。Hyperlinks can also be created in Excel Power Pivot before the workbook is imported into Power BI. 这两种方法都在下面进行了介绍。Both methods are described below.

添加超链接的过程取决于是否已导入数据或使用 DirectQuery 连接至此。The procedure for adding a hyperlink depends on whether you've imported the data or connected to it using DirectQuery. 这两种方案都在下面进行了介绍。Both scenarios are described below.

有关导入到 Power BI 的数据For data imported into Power BI

  1. 如果超链接尚未作为数据集中的字段存在,则使用 Desktop 将其添加为 自定义列If the hyperlink doesn't already exist as a field in your dataset, use Desktop to add it as a custom column.
  2. 在“数据”视图中,选择该列,并在“建模”选项卡上选择“数据类别”下拉列表。In Data view, select the column and in the Modeling tab choose the dropdown for Data Category.

  3. 选择 Web URLSelect Web URL.
  4. 切换到报表视图,并使用归类为 Web URL 的字段创建表或矩阵。Switch to Report view and create a table or matrix using the field categorized as a Web URL. 超链接为蓝色并带有下划线。The hyperlinks will be blue and underlined.

  5. 如果不想在表中显示长 URL,可以改为显示超链接图标 If you don't want to display a long URL in a table, you can display a hyperlink icon instead. 请注意,不能在矩阵中显示图标。Note that you can't display icons in matrixes.

    • 选择图表,使其处于活动状态。Select the chart to make it active.
    • 选择滚动油漆刷图标 ,打开“格式”选项卡。Select the paint roller icon to open the Formatting tab.
    • 展开“”,找到 URL 图标 并将其打开。Expand Values, locate URL icon and turn it to On.
  6. (可选)将报表从 Desktop 发布到 Power BI 服务,并在 Power BI 服务中打开报表。(Optional) Publish the report from Desktop to Power BI service and open the report in Power BI service. 超链接也将在那里运作。The hyperlinks will work there as well.

对于与 DirectQuery 连接的数据For data connected with DirectQuery

将无法在 DirectQuery 模式下创建一个新列。You won't be able to create a new column in DirectQuery mode. 但是,如果数据已包含 URL,可以将这些数据转变为超链接。But if your data already contains URLs, you can turn those into hyperlinks.

  1. 在报表视图中,使用含有 URL 的字段创建表。In Report view, create a table using a field that contains URLs.
  2. 选择该列,并在“建模”选项卡上选择“数据类别”下拉列表。Select the column, and in the Modeling tab, choose the dropdown for Data Category.
  3. 选择 Web URLSelect Web URL. 超链接为蓝色并带有下划线。The hyperlinks will be blue and underlined.
  4. (可选)将报表从 Desktop 发布到 Power BI 服务,并在 Power BI 服务中打开报表。(Optional) Publish the report from Desktop to Power BI service and open the report in Power BI service. 超链接也将在那里运作。The hyperlinks will work there as well.

向 Power BI 表和矩形图添加超链接的另一个方法是从 Power BI 导入/连接到数据集前,在该数据集中创建超链接。Another way to add hyperlinks to your Power BI tables and matrixes is to create the hyperlinks in the dataset before you import/connect to that dataset from Power BI. 本示例使用 Excel 工作簿。This example uses an Excel workbook.

  1. 在 Excel 中打开工作簿。Open the workbook in Excel.
  2. 选择 PowerPivot 选项卡,然后选择管理Select the PowerPivot tab and then choose Manage.

  3. Power Pivot 打开时,选择“高级”选项卡。When PowerPivot opens, select the Advanced tab.

  4. 将光标置于包含你想要将其转换为 Power BI 表中的超链接的 URL 的列。Place your cursor in the column that contains the URLs that you'd like to turn into hyperlinks in Power BI tables.

    请注意:URL 必须以 http:// 、 https://www 开头。NOTE: The URLS must start with http:// , https:// or www.

  5. Reporting 属性组中,选择数据类别下拉列表,然后选择 Web URLIn the Reporting Properties group, select the Data Category dropdown and choose Web URL.

  6. 从 Power BI 服务或 Power BI Desktop 连接到或导入此工作簿。From the Power BI service or Power BI Desktop, connect to or import this workbook.
  7. 创建一个包含 URL 字段的表可视化效果。Create a table visualization that includes the URL field.

注意事项和疑难解答Considerations and troubleshooting

问:是否可以使用自定义 URL 作为表或矩阵中的超链接?Q: Can I use a custom URL as a hyperlink in a table or matrix?
答:不可以。A: No. 可以使用链接图标。You can use a link icon. 如需为你的超链接使用自定义文本且你的 URL 列表较短,请考虑改用文本框。If you need custom text for your hyperlinks and your list of URLs is short, consider using a text box instead.

后续步骤Next steps

Power BI 报表中的可视化效果Visualizations in Power BI reports

Power BI - 基本概念Power BI - Basic Concepts

更多问题?More questions? 尝试参与 Power BI 社区Try the Power BI Community