刷新 OneDrive 或 SharePoint Online 上存储的数据集Refresh a dataset stored on OneDrive or SharePoint Online

将文件从 OneDrive 或 SharePoint Online 导入 Power BI 服务是确保在 Power BI Desktop 上所做的工作与 Power BI 服务保持同步的好方法。Importing files from OneDrive, or SharePoint Online, into the Power BI service is a great way to make sure the work you’re doing in Power BI Desktop stays in sync with the Power BI service.

在 OneDrive 或 SharePoint Online 上存储 Power BI Desktop 文件的好处Advantages of storing a Power BI Desktop file on OneDrive or SharePoint Online

在 OneDrive 或 SharePoint Online 上存储 Power BI Desktop 文件时,已加载到文件模型的任何数据都将被导入到数据集并且在文件中创建的任何报表都会被加载到 Power BI 服务中的报表中。When you store a Power BI Desktop file on OneDrive or SharePoint Online, any data you’ve loaded into your file’s model is imported into the dataset, and any reports you’ve created in the file are loaded into Reports in the Power BI serviced. 对 OneDrive 或 SharePoint Online 上的文件进行更改时,如添加新度量值、更改列名称,或编辑可视化效果,在保存文件后,通常在大约 1 小时内,这些更改也会被更新到 Power BI 服务中。When you make changes to your file on OneDrive or SharePoint Online, such as adding new measures, changing column names, or editing visualizations, once you save the file those changes will be updated in the Power BI service too, usually within about an hour.

你可以直接在 Power BI Desktop 中通过选择主页功能区上的“刷新”手动执行一次性刷新操作。You can perform a one-time, manual refresh right in Power BI Desktop by selecting Refresh on the Home ribbon. 选择此处的“刷新”时,将用原始数据源中更新后的数据刷新文件模型中的数据。When you select Refresh here, the data in the file’s model is refreshed with updated data from the original data source. 这种类型的刷新完全是从 Power BI Desktop 应用程序自身内部进行,不同于在 Power BI 中进行的手动或计划内刷新,理解这种区别至关重要。This kind of refresh, entirely from within the Power BI Desktop application itself, is different from manual or scheduled refresh in Power BI, and it’s important to understand the distinction.

当从 OneDrive 或 SharePoint Online 导入 Power BI Desktop 文件时,此数据以及有关模型的其他信息将被加载到 Power BI 中的数据集。When you import your Power BI Desktop file from OneDrive, or SharePoint Online, data, along with other information about the model is loaded into a dataset in Power BI. 在 Power BI 服务中,而不是在 Power BI Desktop 中,建议刷新数据集中的数据,因为 Power BI 服务中的报表就是基于该数据集创建的。In the Power BI service, not Power BI Desktop, you want to refresh data in the dataset because that is what your reports, in the Power BI service, are based on. 由于该数据源是外部数据源,因此可以手动刷新该数据集,方法是通过使用立即刷新或者可以通过使用计划刷新设置刷新计划。Because the data sources are external, you can manually refresh the dataset by using Refresh now or you can setup a refresh schedule by using Schedule Refresh.

刷新数据集时,Power BI 不会连接到 OneDrive 或 SharePoint Online 上的文件以对更新后的数据进行查询。When you refresh the dataset, Power BI does not connect to the file on OneDrive, or SharePoint Online, to query for updated data. 而是使用数据集中的信息直接连接到数据源对更新后的数据进行查询,然后再将其加载到数据集。It uses information in the dataset to connect directly to the data sources to query for updated data it then loads into the dataset. 数据集中此刷新后的数据不会同步回 OneDrive 或 SharePoint Online 上的文件。This refreshed data in the dataset is not synchronized back to the file on OneDrive, or SharePoint Online.

支持的功能有哪些?What’s supported?

在 Power BI 中,数据集是使用本地驱动器导入的 Power BI Desktop 文件创建的,它支持“立即刷新”和“计划刷新”功能。在本地驱动器中,“获取数据”/“查询编辑器”可用于连接到以下任一数据源并从以下任一数据源加载数据:In Power BI, Refresh Now and Schedule Refresh is supported for datasets created from Power BI Desktop files imported from a local drive where Get Data/Query Editor is used to connect to and load data from any of the following data sources:

Power BI Gateway - PersonalPower BI Gateway - Personal

  • Power BI Desktop“获取数据”和“查询编辑器”中显示的所有联机数据源。All online data sources shown in Power BI Desktop’s Get Data and Query Editor.
  • Power BI Desktop“获取数据”和“查询编辑器”中显示的所有本地数据源,Hadoop 文件 (HDFS) 和 Microsoft Exchange 除外。All on-premises data sources shown in Power BI Desktop’s Get Data and Query Editor except for Hadoop file (HDFS) and Microsoft Exchange.

本地数据网关On-premises data gateway

数据源Data source
Analysis Services 表格Analysis Services Tabular
Analysis Services 多维Analysis Services Multidimensional
SQL ServerSQL Server
SAP HANASAP HANA
OracleOracle
TeradataTeradata
文件File
文件夹Folder
SharePoint 列表(本地)SharePoint list (on-premises)
WebWeb
ODataOData
IBM DB2IBM DB2
MySQLMySQL
SybaseSybase
SAP BWSAP BW
IBM Informix 数据库IBM Informix Database
ODBCODBC

备注

必须安装一个网关并运行该网关,才能使 Power BI 连接到本地数据源并刷新数据集。A gateway must be installed and running in order for Power BI to connect to on-premises data sources and refresh the dataset.

OneDrive 或 OneDrive for Business。OneDrive or OneDrive for Business. 有什么区别?What’s the difference?

如果同时拥有个人 OneDrive 和 OneDrive for Business,建议保留要导入到 OneDrive for Business 中的 Power BI 的所有文件。If you have both a personal OneDrive and OneDrive for Business, it’s recommended you keep any files you want to import into Power BI in OneDrive for Business. 原因如下:你有可能使用两个不同的帐户登录到它们。Here’s why: You likely use two different accounts to sign into them.

连接到 Power BI 中的 OneDrive for Business 通常是无缝的,因为你用于登录 Power BI 的同一个帐户通常是用来登录 OneDrive for Business 的同一个帐户。Connecting to OneDrive for Business in Power BI is typically seamless because the same account you use to sign into Power BI with is often the same account used to sign into OneDrive for Business. 但使用个人 OneDrive 时,你可能需要使用其他 Microsoft 帐户才能登录。But, with personal OneDrive, you likely sign in with a different Microsoft account.

当使用 Microsoft 帐户登录时,请确保选中“使我保持登录状态”。When you sign in with your Microsoft account, be sure to select Keep me signed in. 随后,Power BI 会将在 Power BI Desktop 文件中进行的所有更新与 Power BI 中的数据集同步。Power BI can then synchronize any updates you make in the file in Power BI Desktop with datasets in Power BI

如果对无法与 Power BI 中的数据集或报表进行同步的 OneDrive 文件进行更改,由于 Microsoft 帐户凭据可能已更改,你需要连接到个人 OneDrive 并再次从个人 OneDrive 导入文件。If you make changes to your file on OneDrive that cannot be synchronized with the dataset or reports in Power BI, because your Microsoft account credentials might have changed, you’ll need to connect to and import your file again from your personal OneDrive.

如何设置计划刷新?How do I schedule refresh?

设置刷新计划时,Power BI 将使用数据集中的连接信息和凭据直接连接到数据源,以对更新后的数据进行查询,然后再将更新后的数据加载到数据集。When you setup a refresh schedule, Power BI will connect directly to the data sources using connection information and credentials in the dataset to query for updated data, then load the updated data into the dataset. 此外,还会更新基于 Power BI 服务中该数据集的报表和仪表板中的所有可视化效果。Any visualizations in reports and dashboards based on that dataset in the Power BI service are also updated.

有关如何设置计划刷新的详细信息,请参阅配置计划刷新For details on how to setup schedule refresh, see Configure Schedule Refresh.

出现问题时When things go wrong

出现问题时,通常是因为 Power BI 无法登录数据源,或数据集连接到本地数据源,而网关处于脱机状态。When things go wrong, it’s usually because Power BI can’t sign into data sources, or if the dataset connects to an on-premises data source, the gateway is offline. 确保 Power BI 可以登录数据源。Make sure Power BI can sign into data sources. 如果用于登录数据源的密码更改,或 Power BI 已从数据源注销,请务必在数据源凭据中再次尝试登录数据源。If a password you use to sign into a data source changes, or Power BI gets signed out from a data source, be sure to try signing into your data sources again in Data Source Credentials.

如果对 OneDrive 上的 Power BI Desktop 文件进行更改和保存,在 1 个小时左右内这些更改未反映到 Power BI 上的话,则可能是由于 Power BI 无法连接到 OneDrive。If you’re making changes to the Power BI Desktop file on OneDrive and saving, and those changes aren’t being reflected in Power BI within an hour or so, it could be because Power BI cannot connect to your OneDrive. 再次尝试连接到 OneDrive 上的文件。Try connecting to the file on OneDrive again. 如果系统提示你登录,请确保选中“使我保持登录状态”。If you’re prompted to sign in, make sure you select Keep me signed in. 由于 Power BI 无法连接到 OneDrive 以与文件进行同步,你将需要再次导入你的文件。Because Power BI was not able to connect to your OneDrive to synchronize with the file, you’ll need to import your file again.

请确保选中刷新失败时发送电子邮件通知Be sure to leave the Send refresh failure notification email to me checked. 你会想立即了解计划刷新是否失败。You’ll want to know right away if a scheduled refresh fails.

故障排除Troubleshooting

有时可能不会按预期方式刷新数据。Sometimes refreshing data may not go as expected. 通常,这会是与网关连接出现的问题。Typically this will be an issue connected with a gateway. 请查看网关故障排除文章,了解相关工具和已知问题。Take a look at the gateway troubleshooting articles for tools and known issues.

本地数据网关疑难解答Troubleshooting the on-premises data gateway

Power BI Gateway - Personal 故障排除Troubleshooting the Power BI Gateway - Personal

更多问题?More questions? 尝试咨询 Power BI 社区Try asking the Power BI Community