通过 Power BI Desktop 连接 Power BI 服务中的数据集Connect to datasets in the Power BI service from Power BI Desktop

可以与 Power BI 服务中的共享数据集建立实时连接,并根据同一数据集创建多个不同的报表。You can establish a live connection to a shared dataset in the Power BI service, and create many different reports from the same dataset. 也就是说,可以在 Power BI Desktop 中创建理想的数据模型,将其发布到 Power BI 服务中,然后你和其他人可以根据同一通用数据模型创建多个不同的报表(独立的 .pbix 文件)。This means you can create your perfect data model in Power BI Desktop, publish it to the Power BI service, then you and others can create multiple different reports (in separate .pbix files) from that same, common data model. 我们将此功能称为 Power BI 服务实时连接This features is called Power BI service Live connection.

此功能具有诸多优势(包括用作最佳做法),本文将对此进行介绍。There are all sorts of benefits of this feature, including best practices, which we’ll discuss during this article. 也存在一些注意事项和限制。因此,请务必仔细阅读本文结尾部分介绍的注意事项和限制。There are also a few considerations and limitations, so please make sure you read through those - they're found at the end of this article.

使用 Power BI 服务实时连接管理报表生命周期Using a Power BI service live connection for report lifecycle management

Power BI 的普及带来了一个问题,就是报表、仪表板及其基础数据模型激增。One challenge with the popularity of Power BI is the proliferation of reports, dashboards, and their underlying data models. 如此普及的原因在于,可以轻松地在 Power BI Desktop 中创建富有吸引力的报表,然后将其共享(发布)到 Power BI 服务中,并能通过这些数据集创建精彩的仪表板。Here's why: it's easy to create compelling reports in Power BI Desktop, then share (publish) those reports in the Power BI service, and to create great dashboards from those datasets. 由于许多人都这么做(通常使用的是同一个(或几乎相同的)数据集),因此确定报表是以哪个数据集为依据且每个数据集的新近度就变得很困难。Since so many people were doing so, often using the same (or nearly the same) datasets, knowing which report was based on which dataset - and how fresh each dataset might be - became a challenge. 为了应对这一挑战,我们提供了 Power BI 服务实时连接功能,以便你可以更轻松、一致地创建、共享和扩展通用数据集报表和仪表板。The Power BI service Live Connection addresses that challenge, and makes creating, sharing, and expanding upon common-dataset reports and dashboards easier and consistent.

创建并共享所有人都可以使用的数据集Create a dataset everyone can use, then share it

假设 Anna 是一名业务分析师,同时也是你团队中的一员,她非常擅长创建优质数据模型(通常称为“数据集”)。Let's say Anna (a business analyst) is on your team, and she's great at creating good data models (often called datasets). 借助她自己的专业知识,Anna 可以创建数据集和报表,然后将报表共享到 Power BI 服务中。With Anna's expertise, she can create a dataset and report, and then share that report in the Power BI service.

每个人都很喜欢她的报表和数据集,而问题也随之而来。团队中的每个人都会尝试根据她的数据集创建自己的版本,然后将他们自己的报表与团队共享。Everyone loves her report, and her dataset, and that's where the trouble would begin - everyone on her team would attempt to create their own version of that dataset, then share their own reports with the team. Power BI 服务中,你团队的工作区中突然之间就出现了大量报表(以不同的数据集为依据)。All of the sudden there was a multitude of reports (from different datasets) in your team's workspace in the Power BI service. 哪一个是最新的?Which was the most recent? 这些数据集是完全相同,还只是大致相同?Were the datasets the same, or only almost? 区别在哪里?What were the differences? 借助 Power BI 服务实时连接功能,一切都会有所改善。With the Power BI service Live Connection feature, all that can change for the better. 在下一部分中,我们将了解其他人如何将 Anna 发布的数据集用于自己的报表,以及所有人如何使用同一个已发布且经过审核的可靠数据集来生成自己独一无二的报表。In the next section, we see how others can use Anna's published dataset for their own reports, and enable everyone to use the same solid, vetted, published dataset to build their unique reports.

使用实时连接功能连接 Power BI 服务数据集Connect to a Power BI service dataset using a live connection

创建自己的报表(及其依据的数据集)后,Anna 将报表发布到 Power BI 服务中,此报表显示在 Power BI 服务中她团队的工作区内。Once Anna creates her report (and creates the dataset it's based upon), she publishes it to the Power BI service, it shows up in her team's workspace in the Power BI service. 现在,她的工作区中的每个人都可以查看并使用此报表。Now it's available for everyone in her workspace to see and use.

她的工作区中的其他成员现在可以与 Anna 共享的数据模型建立实时连接(使用 Power BI 服务实时连接功能),并根据她的原始数据集创建自己独一无二的报表。Other members of her workspace can now establish a live connection to Anna's shared data model (using the Power BI service live connection feature), and create their own unique reports, from her original dataset.

下图展示了 Anna 是如何创建一个 Power BI Desktop 报表,并将其(包括它的数据模型)发布到 Power BI 服务中的。In the following image, you see how Anna creates one Power BI Desktop report, and publishes it (which includes its data model) to the Power BI service. 然后,她的工作区中的其他成员可以使用 Power BI 服务实时连接功能连接她的数据模型,并根据她的数据集创建自己独一无二的报表。Then others in her workspace can connect to her data model using the Power BI service live connection, and create their own unique reports based on her dataset.

备注

数据集只在一个工作区中进行共享。Datasets are only shared in one workspace. 要连接的数据集必须位于你所属的共享工作区中,才能建立 Power BI 服务实时连接。To establish a Power BI service live connection, the dataset to which you connect must be in a shared workspace of which you are a member.

使用 Power BI 服务实时连接的分步流程Step-by-step for using the Power BI service live connection

至此,我们已经了解 Power BI 服务实时连接是多么实用,以及如何将此功能用作管理报表生命周期的最佳做法。接下来,我们逐步了解如何将 Anna 的优质报表(和数据集)变成她的 Power BI 工作区中的同事可以使用的共享数据集。Now that we know how useful the Power BI service live connection is, and how you can use it as a best practice approach to report lifecycle management, let's walk through the steps that get us from Anna's great report (and dataset) to a shared dataset that teammates in her Power BI workspace can use.

发布 Power BI 报表和数据集Publish a Power BI report and dataset

使用 Power BI 服务实时连接管理报表生命周期的第一步是,创建并共享同事想要使用的报表(和数据集)。The first step in managing the report lifecycle using a Power BI service live connection is to have a report (and dataset) that teammates want to use. 因此,Anna 必须先从 Power BI Destkop 发布她的报表。So Anna must first publish her report from Power BI Destkop. 为此,她在 Power BI Desktop 的“开始”功能区中选择“发布”。She does this by selecting Publish from the Home ribbon in Power BI Desktop.

如果尚未登录 Power BI 服务帐户,系统将会提示她登录。If she isn't signed in to her Power BI service account, she's prompted to do so.

随后,她可以选择要将报表和数据集发布到的目标工作区。From there, she can choose the workspace destination to which the report and dataset will be published. 请注意,只有有权访问报表发布到的工作区的成员才能使用 Power BI 服务实时连接访问报表的数据集。Remember, only members who have access to the workspace where a report is published can access its dataset using a Power BI service live connection.

此时便会开始发布,Power BI Desktop 会显示发布进度。The publishing process begins, and Power BI Desktop shows the progress.

完成后,Power BI Desktop 会提示发布成功,并显示两个链接,一个链接用于转到 Power BI 服务访问报表本身,另一个链接用于获取有关报表的快速见解Once complete, Power BI Desktop shows you success, and provides a couple links to get you to the report itself in the Power BI service, and a link to get Quick Insights on the report.

接下来,让我们来看一下有权访问报表(和数据集)发布到的工作区的其他同事如何连接数据集并生成自己的报表。Next, let's see how other teammates who have access to the workspace where the report (and dataset) were published can connect to the dataset and build our own reports.

与已发布的数据集建立 Power BI 服务实时连接Establish a Power BI service live connection to the published dataset

若要与已发布的报表建立连接,并根据已发布的数据集创建自己的报表,请在 Power BI Desktop 的“开始”功能区中依次选择“获取数据”和“Power BI 服务”。To establish a connection to the published report, and create your own report based on the published dataset, select Get Data from the Home ribbon in Power BI Desktop, and select Power BI service. 也可以依次选择“获取数据”>“联机服务”>“Power BI 服务”。You can also select it from Get Data > Online Services > Power BI service.

如果尚未登录 Power BI,系统将会提示你登录。If you're not signed in to Power BI, you'll be prompted to do so. 登录后,便会看到一个窗口,其中显示你所属的工作区,你可以选择包含要与其建立 Power BI 服务实时连接的数据集的工作区。Once logged in, you're presented with a window that shows which workspaces you're a member of, and you can select which workspace contains the dataset to which you want to establish a Power BI service live connection.

工作区旁边括号中的数字表示相应工作组中有多少个共享数据集,选择左侧的三角形可以展开工作区并选择共享数据集。The number in brackets beside the workspace shows how many shared datasets are available in that workgroup, and selecting the triangle to the left expands the workspace, allowing you to select the shared dataset.

对于上面的 Power BI 服务实时连接窗口,需要注意下面几点事项:There are a few items to note from the previous Power BI service live connection window:

  • 可以搜索共享数据集,但搜索结果范围仅限于展开的工作区,不会搜索未展开的任何工作区。You can search for a shared dataset, but the search results are limited to the expanded items, and won't include any workspaces that you have not expanded.
  • 可以展开多个工作区来扩大搜索范围。You can expand more than one workspace to expand your search.

选择窗口中的“加载”后,便与所选的数据集建立了实时连接。也就是说,所看到的数据(字段及其值)已实时加载到 Power BI Desktop 中。When you select Load from the window, you establish a live connection to the selected dataset, which means the data you see (the fields, and their values) are loaded into Power BI Desktop in real time.

现在,你(及其他人)可以创建并共享自定义报表,全部都是以同一个数据集为依据。Now you (and others) can create and share custom reports and share them, all from the same dataset. 让一个拥有丰富专业知识的人创建格式正确的数据集(就像 Anna 所做),然后允许很多同事使用此共享数据集创建他们自己的报表,不失为一种很好的方法。This is a great way to have one knowledgeable person create a well-formed dataset (such as what Anna does), and allow many teammates use that shared dataset to create their own reports.

备注

当基于使用与 Power BI 服务实时连接的数据集创建报表时,只能将该报表发布到包含所使用数据集的同一 Power BI 服务工作区。When you create reports based on dataset using a live connection to the Power BI service, you can only publish that report to the same Power BI service workspace that contains the dataset being used.

限制和注意事项Limitations and considerations

使用 Power BI 服务实时连接时,需要遵循几项限制和注意事项。When using the Power BI service live connection, there are a few limitations and considerations to keep in mind.

  • 工作区的只读成员无法连接到 Power BI Desktop 中的数据集。Read-only members of a workspace cannot connect to datasets from Power BI Desktop.
  • 只有属于同一个 Power BI 服务工作区的用户,才能使用 Power BI 服务实时连接功能连接已发布的数据集。Only users who are part of the same Power BI service workspace can connect to a published dataset using the Power BI service live connection. 用户可以属于多个工作区(通常情况下确实如此)。Users can (and often do) belong to more than one workspace.
  • 由于这是实时连接,因此禁用左导航和建模,与连接 SQL Server Analysis Services 时的行为相似。Since this is a live connection, left-navigation and modeling are disabled, similar to the behavior when connected to SQL Server Analysis Services.
  • 由于这是实时连接,因此将强制执行 RLS(行级和角色级安全)、OneDrive for Business 和其他此类连接行为,与连接 SQL Server Analysis Services 时的情况相似。Since this is a live connection, RLS (row- and role-level security), OneDrive for Business, and other such connection behaviors are enforced, just as they are when connected to SQL Server Analysis Services.
  • 选择要连接 Power BI 服务中的哪一个数据集时,搜索框的搜索范围仅限于已展开的工作区。When selecting which dataset to connect to in the Power BI service, the search box only applies to workspaces that have been expanded.
  • 如果修改原始的共享 .pbix 文件,共享到 Power BI 服务的数据集和报表将会被覆盖。If you modify the original shared .pbix file, the dataset and report that is shared in the Power BI service is overwritten.
  • 无法替换初始共享报表。You cannot replace the originally shared report. 尝试执行此操作会导致出现警告,提示你重命名文件后再进行发布。Attempts to do so result in a warning that prompts you to rename the file, and publish.
  • 如果删除 Power BI 服务中的共享数据集,那么其他 Power BI Desktop (.pbix) 文件将无法再正常运行或显示其视觉对象。If you delete the shared dataset in the Power BI service, then other Power BI Desktop (.pbix files) will no longer work properly or display their visuals.
  • 对于内容包,必须先创建内容包的副本,然后才能以此为基础将 .pbix 报表和数据集共享到 Power BI 服务中。For Content Packs, you must first create a copy of a content pack before using it as a basis for sharing a .pbix report and dataset to the Power BI service.
  • 对于来自我的组织的内容包,一旦复制,则无法替换在此服务上创建的报表和/或作为使用实时连接复制内容包的一部分创建的报表。For Content Packs from My Organization, once copied, you cannot replace the report created on the service and/or a report created as part of copying a Content Pack with a live connection. 尝试执行此操作会导致出现警告,提示你重命名文件后再进行发布。Attempts to do so result in a warning that prompts you to rename the file, and publish. 在这种情况下,只能替换已发布的实时连接的报表。In this situation, you can only replace published live connected reports.
  • 基于使用与 Power BI 服务实时连接的数据集创建报表时,只能将该报表发布到包含所使用数据集的同一 Power BI 服务工作区。When you create a report based on dataset using a live connection to the Power BI service, you can only publish that report to the same Power BI service workspace that contains the dataset being used.
  • 删除 Power BI 服务中的共享数据集意味着无法再从 Power BI Desktop 访问该数据集。Deleting a shared dataset in the Power BI service means you can no longer access that dataset from Power BI Desktop.