Power BI 中的数据刷新Data refresh in Power BI

确保始终获得最新数据对于制定正确决策通常是至关重要的。Making sure you’re always getting the latest data is often critical in making the right decisions. 你可能已在 Power BI 中使用“获取数据”连接到并上载一些数据,创建了一些报表和仪表板。You’ve probably already used Get Data in Power BI to connect to and upload some data, created some reports and a dashboard. 现在,你要确保数据确实是最新且最好的。Now, you want to make sure your data really is the latest and greatest.

在许多情况下,完全无需执行任何操作。In many cases, you don’t need to do anything at all. 某些数据(如来自 Salesforce 或 Marketo 内容包的数据)会自动为你刷新。Some data, like from a Salesforce or Marketo content pack is automatically refreshed for you. 如果连接使用了实时连接或 DirectQuery,则数据会更新为最新状态。If your connection makes use of a live connection or DirectQuery, the data will be update to date. 但是在其他情况下,与连接到外部联机或本地数据源的 Excel 工作簿或 Power BI Desktop 文件一样,需要手动刷新或设置刷新计划,以便 Power BI 可以为你刷新报表和仪表板中的数据。But, in other cases, like with an Excel workbook or Power BI Desktop file that connects to an external online or on-premises data source, you’ll need to refresh manually or setup a refresh schedule so Power BI can refresh the data in your reports and dashboards for you.

本文以及一些其他文章旨在帮助你了解 Power BI 中的数据刷新的实际工作原理、是否需要设置刷新计划以及成功刷新数据所需要完成的工作。This article, along with a few others, are meant to help you understand how data refresh in Power BI really works, whether or not you need to setup a refresh schedule, and what needs to be in-place to refresh your data successfully.

了解数据刷新Understanding data refresh

设置刷新之前,请务必了解所刷新的内容以及在何处获取数据。Before setting up refresh, it’s important to understand what it is you’re refreshing and where you’re getting your data.

数据源是在报表和仪表板中浏览的数据的实际来源;例如,联机服务(如 Google Analytics 或 QuickBooks)、云中的数据库(如 Azure SQL 数据库)或者自己组织中的本地计算机或服务器上的数据库或文件。A data source is where the data you explore in your reports and dashboards really comes from; for example, an online service like Google Analytics or QuickBooks, a database in the cloud like Azure SQL Database, or a database or file on a local computer or server in your own organization. 这些都是数据源。These are all data sources. 数据源的类型确定如何刷新其中的数据。The type of data source determines how data from it is refreshed. 稍后我们会在可以刷新的内容部分中介绍每种数据源类型的刷新。We’ll go into refresh for each type of data source a little later in the What can be refreshed? section.

使用“获取数据”连接到数据以及从内容包、文件上载数据或是连接到实时数据源时,会自动在 Power BI 中创建数据集。A dataset is automatically created in Power BI when you use Get Data to connect to and upload data from a content pack, file, or you connect to a live data source. 在 Power BI Desktop 和 Excel 2016 中,还可以将文件直接发布到 Power BI 服务(就如同使用“获取数据”一样)。In Power BI Desktop and Excel 2016, you can also publish your file right to the Power BI service, which is just like using Get Data.

在每种情况下,都会在 Power BI 服务中的“我的工作区”(或“组”)容器中创建并显示数据集。In each case, a dataset is created and appears in the My Workspace, or Group, containers in the Power BI service. 对数据集选择省略号 (...) 时,可以浏览报表中的数据、编辑设置以及设置刷新。When you select the ellipse (...) for a dataset, you can explore the data in a report, edit settings, and setup refresh.

数据集可以从一个或多个数据源获取数据。A dataset can get data from one or more data sources. 例如,可以使用 Power BI Desktop 从组织中的 SQL 数据库中获取数据,并从联机 OData 源获取其他数据。For example, you can use Power BI Desktop to get data from a SQL Database in your organization, and get other data from an OData feed online. 随后在将文件发布到 Power BI 中时,会创建单个数据集,但是它同时包含用于 SQL 数据库和 OData 源的数据源。Then, when you publish the file to Power BI, a single dataset is created, but it will have data sources for both the SQL Database and the OData feed.

数据集包含有关数据源的信息、数据源凭据以及(在大多数情况下)从数据源复制的数据的子集。A dataset contains information about the data sources, data source credentials, and in most cases, a sub-set of data copied from the data source. 在报表和仪表板中创建可视化效果时,你会查看数据集中的数据,或对于实时连接(如 Azure SQL 数据库),数据集会定义你直接从数据源查看的数据。When you create visualizations in reports and dashboards, you’re looking at data in the dataset, or in the case of a live connection like Azure SQL Database, the dataset defines the data you see right from the data source. 对于与 Analysis Services 之间的实时连接,数据集定义直接来自 Analysis Services。For a live connection to Analysis Services, the dataset definition comes from Analysis Services directly.

刷新数据时,会从数据源更新存储在 Power BI 中的数据集中的数据。此刷新是完全刷新,不是增量刷新。When you refresh data, you are updating the data in the dataset that is stored in Power BI from your data source. This refresh is a full refresh and not incremental.

每次刷新数据集中的数据时(无论是使用“立即刷新”还是通过设置刷新计划),Power BI 都会使用数据集中的信息连接到为其定义的数据源,查询更新的数据,然后将更新的数据加载到数据集中。Whenever you refresh data in a dataset, whether by using Refresh Now or by setting up a refresh schedule, Power BI uses information in the dataset to connect to the data sources defined for it, query for updated data, and then loads the updated data into the dataset. 报表或仪表板中基于这些数据的任何可视化效果都会自动更新。Any visualizations in your reports or dashboards based on the data are updated automatically.

继续讨论之前,有其他一些需要了解的重要事项:Before we go any further, there’s something else that's very important to understand:

无论以何种频率刷新数据集,或是以何种频率查看实时数据,都必须首先更新数据源中的数据。Regardless of how often you refresh the dataset, or how often you look at live data, it is the data at the data source that must be up-to-date first.

大多数组织一天处理一次数据(通常在晚上)。Most organizations process their data once a day, usually in the evening. 如果针对从连接到本地数据库的 Power BI Desktop 文件创建的数据集计划刷新,并且 IT 部门在晚上对该 SQL 数据库运行一次处理,则只需将计划的刷新设置为一天运行一次。If you schedule refresh for a dataset created from a Power BI Desktop file that connects to an on-premises database, and your IT department runs processing on that SQL database once in the evening, then you only need to setup scheduled refresh to run once-a-day. 例如,对数据库进行处理之后,但是在你进入工作之前。For example, after processing on the database happens, but before you come into work. 当然,并非总是这种情况。Of course, this isn’t always the case. Power BI 提供了许多方法来连接到经常更新甚至是实时更新的数据源。Power BI provides many ways to connect to data sources that are updated frequently or even real-time.

刷新的类型Types of refresh

在 Power BI 中进行的刷新有四种主要类型。There are four main types of refresh that happen within Power BI. 包刷新、模型/数据刷新、磁贴刷新和视觉对象容器刷新。Package refresh, model/data refresh, tile refresh and visual container refresh.

包刷新Package refresh

这会在 Power BI 服务与 OneDrive(或 SharePoint Online)之间同步 Power BI Desktop(或 Excel)文件。This synchronizes your Power BI Desktop, or Excel, file between the Power BI service and OneDrive, or SharePoint Online. 这不会从原始数据源请求数据。This does not pull data from the original data source. Power BI 中的数据集只使用 OneDrive(或 SharePoint Online)中的文件内容进行更新。The dataset in Power BI will only be updated with what is in the file within OneDrive, or SharePoint Online.

模型/数据刷新Model/data refresh

这指的是在 Power BI 服务中使用来自原始数据源的数据刷新数据集。This is referring to refreshing the dataset, within the Power BI service, with data from the original data source. 这使用计划的刷新或立即刷新来进行。This is done by either using scheduled refresh, or refresh now. 对于本地数据源,这需要网关。This requires a gateway for on-premises data sources.

磁贴刷新Tile refresh

在数据更改之后,磁贴刷新会为仪表板上的磁贴视觉对象更新缓存。Tile refresh updates the cache for tile visuals, on the dashboard, once data changes. 这大约每十五分钟进行一次。This happens about every fifteen minutes. 还可以通过选择仪表板右上角的“省略号 (...)”并选择“刷新仪表板磁贴”来强制进行磁贴刷新。You can also force a tile refresh by selecting the ellipsis (...) in the upper right of a dashboard and selecting Refresh dashboard tiles.

有关常见磁贴刷新错误的详细信息,请参阅磁贴错误故障排除For details around common tile refresh errors, see Troubleshooting tile errors.

视觉对象容器刷新Visual container refresh

在数据更改之后,刷新视觉对象容器会在报表中更新缓存的报表视觉对象。Refreshing the visual container updates the cached report visuals, within a report, once the data changes.

可以刷新的内容What can be refreshed?

在 Power BI 中,通常使用“获取数据”从位于本地驱动器、OneDrive 或 SharePoint Online 上的文件导入数据、从 Power BI Desktop 发布报表或直接连接到你自己组织的云环境中的数据库。In Power BI, you’ll typically use Get Data to import data from a file on a local drive, OneDrive or SharePoint Online, publish a report from Power BI Desktop, or connect directly to a database in the cloud in your own organization. 可以刷新 Power BI 中的几乎任何数据,不过是否需要则取决于创建数据集的方式以及它连接到的数据源。Just about any data in Power BI can be refreshed, but whether or not you need to depends on how your dataset was created from and the data sources it connects to. 我们来看看在每种情况下如何刷新数据。Let’s look at how each of these refresh data.

继续讨论之前,下面是一些需要了解的重要定义:Before we go further, here are some important definitions to understand:

自动刷新 - 这表示无需进行任何用户配置,数据集即可定期刷新。Automatic refresh - This means no user configuration is necessary in order for the dataset to be refreshed on a regular basis. 由 Power BI 为你配置数据刷新设置。Data refresh settings are configured for you by Power BI. 对于联机服务提供程序,刷新通常一天进行一次。For online service providers, refresh usually occurs once-a-day. 对于从 OneDrive 加载的文件,大约每小时针对不是来自外部数据源的数据进行一次自动刷新。For files loaded from OneDrive, automatic refresh occurs about every hour for data that does not come from an external data source. 虽然可以配置不同的计划刷新设置以及手动刷新,不过可能不需要。While you can configure different schedule refresh settings and manually refresh, you probably don’t need to.

用户配置的手动或计划的刷新 – 这表示可以使用“立即刷新”来手动刷新数据集,或是使用数据集设置中的“计划刷新”来设置刷新计划。User configured manual or scheduled refresh – This means you can manually refresh a dataset by using Refresh Now or setup a refresh schedule by using Schedule Refresh in a dataset’s settings. 对于连接到外部联机和本地数据源的 Power BI Desktop 文件和 Excel 工作簿,需要这种类型的刷新。This type of refresh is required for Power BI Desktop files and Excel workbooks that connect to external online and on-premises data sources.

备注

配置计划刷新的时间后,可能会滞后长达 1 小时才能开始刷新数据。When you configure a time for scheduled refresh, there can be a delay of up to one hour before it begins.

实时/DirectQuery – 这表示 Power BI 与数据源之间存在实时连接。Live/DirectQuery – This means there is a live connection between Power BI and the data source. 对于本地数据源,管理员需要在企业网关中配置数据源,但是可能不需要用户交互。For on-premises data sources, Admins will need to have a data source configured within an enterprise gateway, but user interaction may not be needed.

备注

为了增强性能,具有使用 DirectQuery 连接的数据的仪表板会自动更新。To enhance performance, dashboards with data connected using DirectQuery are automatically updated. 你也可以随时使用磁贴上的“更多”菜单手动刷新该磁贴。You can also manually refresh a tile at any time, by using the More menu on the tile.

本地文件和 OneDrive 或 SharePoint Online 上的文件Local files and files on OneDrive or SharePoint Online

对于连接到外部联机或本地数据源的 Power BI Desktop 文件和 Excel 工作簿,支持数据刷新。Data refresh is supported for Power BI Desktop files and Excel workbooks that connect to external online or on-premises data sources. 这只会为 Power BI 服务中的数据集刷新数据。This will only refresh the data for the dataset within the Power BI service. 它不会更新本地文件。It will not update your local file.

将文件保留在 OneDrive(或 SharePoint Online)上并从 Power BI 连接到它们可提供非常高的灵活性。Keeping your files on OneDrive, or SharePoint Online, and connecting to them from Power BI, provides a great amount of flexibility. 不过与这一灵活性随之而来的,是它也成为最难以理解的情况之一。But with all that flexibility, it also makes it one of the most challenging to understand. 针对存储在 OneDrive(或 SharePoint Online)中的文件的计划的刷新与包刷新不同。Scheduled refresh for files stored in OneDrive, or SharePoint Online, are different from package refresh. 可以在刷新的类型部分中了解详细信息。You can learn more in the Types of refresh section.

Power BI Desktop 文件Power BI Desktop file

数据源Data source 自动刷新Automatic refresh 用户配置的手动或计划的刷新User configured manual or scheduled refresh 需要网关Gateway required
“获取数据”(在功能区中)用于连接到任何列出的联机数据源并从中查询数据。Get Data (on the ribbon) is used to connect to and query data from any listed online data source. No Yes 否(见下文)No (see below)
“获取数据”用于连接到并浏览实时 Analysis Services 数据库。Get Data is used to connect to and explore a live Analysis Services database. Yes No Yes
“获取数据”用于连接到并浏览支持的本地 DirectQuery 数据源。Get Data is used to connect to and explore a supported on-premises DirectQuery data source. Yes No Yes
“获取数据”用于连接到 Azure SQL 数据库、Azure SQL 数据仓库、Azure HDInsight Spark 并从中查询数据。Get Data is used to connect to and query data from an Azure SQL Database, Azure SQL Data Warehouse, Azure HDInsight Spark. Yes Yes No
“获取数据”用于连接到任何列出的本地数据源(Hadoop 文件 (HDFS) 和 Microsoft Exchange 除外)并从中查询数据。Get Data is used to connect to and query data from any listed on-premises data source except for Hadoop file (HDFS) and Microsoft Exchange. No Yes Yes

备注

使用 Web.Page 功能时,如果已重新发布 2016 年 11 月 18 日之后的数据集或报表,将需要网关。If you are using the Web.Page function, you do need a gateway if you have republished the dataset or your report after November 18th, 2016.

有关详细信息,请参阅刷新从 OneDrive 上的 Power BI Desktop 文件创建的数据集For details, see Refresh a dataset created from a Power BI Desktop file on OneDrive.

Excel 工作簿Excel workbook

数据源Data source 自动刷新Automatic refresh 用户配置的手动或计划的刷新User configured manual or scheduled refresh 需要网关Gateway required
未加载到 Excel 数据模型中的工作表中的数据表。Tables of data in a worksheet not loaded into the Excel data model. 是,每小时(仅限 OneDrive/SharePoint Online)Yes, hourly (OneDrive/SharePoint Online only) 仅限手动(仅限 OneDrive/SharePoint Online)Manual only (OneDrive/SharePoint Online only) No
链接到 Excel 数据模型中的表(链接表)的工作表中的数据表。Tables of data in a worksheet linked to a table in the Excel data model (linked tables). 是,每小时(仅限 OneDrive/SharePoint Online)Yes, hourly (OneDrive/SharePoint Online only) 仅限手动(仅限 OneDrive/SharePoint Online)Manual only (OneDrive/SharePoint Online only) No
Power Query* 用于连接到任何列出的联机数据源并从中查询数据,以及将数据加载到 Excel 数据模型中。Power Query* is used to connect to and query data from any listed online data source and load data into the Excel data model. No Yes No
Power Query* 用于连接到任何列出的本地数据源(Hadoop 文件 (HDFS) 和 Microsoft Exchange 除外)并从中查询数据,以及将数据加载到 Excel 数据模型中。Power Query* is used to connect to and query data from any listed on-premises data source except for Hadoop file (HDFS) and Microsoft Exchange and load data into the Excel data model. No Yes Yes
Power Pivot 用于连接到任何列出的联机数据源并从中查询数据,以及将数据加载到 Excel 数据模型中。Power Pivot is used to connect to and query data from any listed online data source and load data into the Excel data model. No Yes No
Power Pivot 用于连接到任何列出的本地数据源并从中查询数据,以及将数据加载到 Excel 数据模型中。Power Pivot is used to connect to and query data from any listed on-premises data source and load data into the Excel data model. No Yes Yes

*Power Query 在 Excel 2016 中名为“获取并转换数据”。* Power Query is known as Get & Transform Data in Excel 2016.

有关详细信息,请参阅刷新从 OneDrive 上的 Excel 工作簿创建的数据集For more detailed information, see Refresh a dataset created from an Excel workbook on OneDrive.

OneDrive 或 SharePoint Online 上的逗号分隔值 (.csv) 文件Comma separated value (.csv) file on OneDrive or SharePoint Online

数据源Data source 自动刷新Automatic refresh 用户配置的手动或计划的刷新User configured manual or scheduled refresh 需要网关Gateway required
简单的逗号分隔值Simple comma separated value 是,每小时Yes, hourly 仅限手动Manual only No

有关详细信息,请参阅刷新从 OneDrive 上的逗号分隔值 (.csv) 文件创建的数据集For more detailed information, see Refresh a dataset created from a comma separated value (.csv) file on OneDrive.

内容包Content packs

Power BI 中有两种类型的内容包:There are two types of content packs in Power BI:

来自联机服务的内容包:如 Adobe Analytics、SalesForce 和 Dynamics CRM Online。Content packs from online services: like Adobe Analytics, SalesForce, and Dynamics CRM Online. 从联机服务创建的数据集一天自动刷新一次。Datasets created from online services are refreshed automatically once a day. 尽管可能不需要,不过可以手动刷新或设置刷新计划。While it’s probably not necessary, you can manually refresh or setup a refresh schedule. 由于联机服务处于云中,因此不需要网关。Because online services are in the cloud, a gateway is not required.

组织内容包:由你自己组织中的用户创建并共享。Organizational content packs: created and shared by users in your own organization. 内容包使用者无法设置刷新计划或手动刷新。Content pack consumers cannot setup a refresh schedule or manually refresh. 只有内容包创建者才能为内容包中的数据集设置刷新。Only the content pack creator can setup refresh for the datasets in the content pack. 刷新设置随数据集一起继承。Refresh settings are inherited with the dataset.

来自联机服务的内容包Content packs from online services

数据源Data source 自动刷新Automatic refresh 用户配置的手动或计划的刷新User configured manual or scheduled refresh 需要网关Gateway required
“获取数据”>“服务”中的联机服务Online services in Get Data > Services Yes Yes No

组织内容包Organizational content packs

包含在组织内容包中的数据集的刷新功能取决于数据集。Refresh capabilities for a dataset included within an organization content pack depends on the dataset. 请参阅上面与本地文件、OneDrive 或 SharePoint Online 相关的信息。See information above in relation to local files, OneDrive or SharePoint Online.

若要了解详细信息,请参阅组织内容包简介To learn more, see Introduction to organizational content packs.

与本地数据源之间的实时连接和 DirectQueryLive connections and DirectQuery to on-premises data sources

借助本地数据网关,可以从 Power BI 向本地数据源发出查询。With the on-premises data gateway, you can issue queries from Power BI to your on-premises data sources. 与可视化效果交互时,查询会从 Power BI 直接发送到数据库。When you interact with a visualization, queries are sent from Power BI directly to the database. 随后会返回更新的数据并更新可视化效果。Updated data is then returned and visualizations are updated. 由于 Power BI 与数据库之间存在直接连接,因此无需计划刷新。Because there is a direct connection between Power BI and the database, there is no need to schedule refresh.

使用实时连接连接到 SQL Service Analysis Services (SSAS) 数据源与使用 DirectQuery 不同,与 SSAS 源的实时连接可以针对缓存运行,即使是在加载报表后,也不例外。When connecting to a SQL Service Analysis Services (SSAS) data source using a Live connection, unlike DirectQuery, the Live connection to a SSAS source can run against the cache, even upon loading a report. 此行为提升了报表的加载性能。This behavior improves load performance for the report. 可以使用“刷新”按钮,从 SSAS 数据源请求获取最新数据。You can request the latest data from the SSAS data source by using the refresh button. SSAS 数据源的所有者可以为数据集配置计划缓存刷新频次,确保报表按照所需的频次不断更新。Owners of SSAS data sources can configure the scheduled cache refresh frequency for the dataset to ensure reports are as up to date as they require.

使用本地数据网关配置数据源时,可以将该数据源用作计划的刷新选项。When you configure a data source with the on-premises data gateway, you can use that data source as the scheduled refresh option. 这会代替使用个人网关。This would be instead of using the personal gateway.

备注

如果为数据集配置了实时或 DirectQuery 连接,数据集大约会每小时刷新一次,或在发生数据交互时进行刷新。If your dataset is configured for a live or DirectQuery connection, datasets are refreshed approximately each hour or when interaction with the data occurs. 可以在 Power BI 服务的“计划的缓存刷新”选项中手动调整刷新频率。You can manually adjust the refresh frequency in the Scheduled cache refresh option in the Power BI service.

数据源Data source 实时/DirectQueryLive/DirectQuery 用户配置的手动或计划的刷新User configured manual or scheduled refresh 需要网关Gateway required
Analysis Services 表格Analysis Services Tabular Yes Yes Yes
Analysis Services 多维Analysis Services Multidimensional Yes Yes Yes
SQL ServerSQL Server Yes Yes Yes
SAP HANASAP HANA Yes Yes Yes
OracleOracle Yes Yes Yes
TeradataTeradata Yes Yes Yes

若要了解详细信息,请参阅本地数据网关To learn more, see On-premises data gateway

云中的数据库Databases in the cloud

使用 DirectQuery 时,Power BI 与云中的数据源之间存在直接连接。With DirectQuery, there is a direct connection between Power BI and the database in the cloud. 与可视化效果交互时,查询会从 Power BI 直接发送到数据库。When you interact with a visualization, queries are sent from Power BI directly to the database. 随后会返回更新的数据并更新可视化效果。Updated data is then returned and visualizations are updated. 而且,由于 Power BI 服务和数据源都处于云中,因此不需要个人网关。And, because both the Power BI service and the data source are in the cloud, there is no need for a Personal Gateway.

如果可视化效果没有发生用户交互,数据大约会每小时自动刷新一次。If there is no user interaction in a visualization, data is refreshed automatically approximately every hour. 可以使用“计划的缓存刷新”选项更改刷新频率,并能设置刷新频率。You can change that refresh frequency using the Scheduled cache refresh option, and set the refresh frequency.

若要设置刷新频率,请选择 Power BI 服务右上角的齿轮图标,然后选择“设置”。To set the frequency, select the gear icon in the upper right corner of the Power BI service, then select Settings.

此时,你会看到“设置”页,可以在其中选择要调整其刷新频率的数据集。The Settings page appears, where you can select the dataset for which you want to adjust the frequency. 在此页上,选择最上面一列中的“数据集”选项卡。On that page, select the Datasets tab along the top.

选择数据集,然后右窗格中会显示此数据集适用的一组选项。Select the dataset, and in the right pane you'll see a collection of options for that dataset. 对于 DirectQuery/实时连接,可以使用相关的下拉菜单设置刷新频率(从 15 分钟刷新一次到每周刷新一次),如下图所示。For the DirectQuery/Live connection, you can set the refresh frequency from 15 minutes to weekly using the associated drop-down menu, as shown in the following image.

数据源Data source 实时/DirectQueryLive/DirectQuery 用户配置的手动或计划的刷新User configured manual or scheduled refresh 需要网关Gateway required
SQL Azure 数据仓库SQL Azure Data Warehouse Yes Yes No
HDInsight 上的 SparkSpark on HDInsight Yes Yes No

若要了解详细信息,请参阅 Azure 和 Power BITo learn more, see Azure and Power BI.

实时仪表板Real-time dashboards

实时仪表板使用 Microsoft Power BI REST API 或 Microsoft Stream Analytics 来确保数据是最新状态。Real-time dashboards use the Microsoft Power BI REST API, or Microsoft Stream Analytics, to make sure the data is up-to-date. 由于实时仪表板不需要用户配置刷新,因此它们不在本文讨论范围之内。Since real time dashboards do not require users to configure refresh, they are outside the scope of this article.

数据源Data source 自动Automatic 用户配置的手动或计划的刷新User configured manual or scheduled refresh 需要网关Gateway required
使用 Power BI Rest API 或 Microsoft Stream Analytics 开发的自定义应用Custom apps developed with the Power BI Rest API or Microsoft Stream Analytics 是,实时流式处理Yes, live streaming No No

若要了解详细信息,请参阅在 Power BI 中创建实时仪表板To learn more, see Create a real-time dashboard in Power BI.

配置计划的刷新Configure scheduled refresh

若要了解如何配置计划的刷新,请参阅配置计划的刷新To learn how to configure scheduled refresh, see Configure scheduled refresh

常见数据刷新方案Common data refresh scenarios

有时,了解 Power BI 中的数据刷新的最佳方法是查看示例。Sometimes the best way to learn about data refresh in Power BI to look at examples. 下面是一些较常见的数据刷新方案:Here are some of the more common data refresh scenarios:

包含数据表的 Excel 工作簿Excel workbook with tables of data

你的 Excel 工作簿包含多个数据表,但它们都未加载到 Excel 数据模型中。You have an Excel workbook with several tables of data, but none of them are loaded into the Excel data model. 你使用“获取数据”将工作簿文件从本地驱动器上载到 Power BI 中,然后创建一个仪表板。You use Get Data to upload the workbook file from your local drive into Power BI, and create a dashboard. 但是,现在你在本地驱动器上对工作簿的几个表进行了一些更改,要使用新数据在 Power BI 中更新仪表板。But, now you’ve made some changes to a couple of the workbook’s tables on your local drive, and you want to update your dashboard in Power BI with the new data.

遗憾的是,此方案中不支持刷新。Unfortunately, refresh is not supported in this scenario. 若要为仪表板刷新数据集,你必须重新上载工作簿。In order to refresh the dataset for your dashboard, you will have to re-upload the workbook. 但是,有一个确实很棒的解决方案:将工作簿文件置于 OneDrive 或 SharePoint Online 上!However, there’s a really great solution: Put your workbook file on OneDrive, or SharePoint Online!

连接到 OneDrive 或 SharePoint Online 上的文件时,报表和仪表板会按照文件中的形式显示数据。When you connect to a file on OneDrive, or SharePoint Online, your reports and dashboards will show data as it is in the file. 在此例中,这是你的 Excel 工作簿。In this case, your Excel workbook. Power BI 会大约每小时自动检查文件是否存在更新。Power BI automatically checks the file, about every hour, for updates. 如果对工作簿(存储在 OneDrive 或 SharePoint Online 中)进行了更改,则这些更改会在一小时内反映在仪表板和报表中。If you make changes to the workbook (stored in OneDrive or SharePoint Online), those changes are reflected in your dashboard and reports within an hour. 完全无需设置刷新。You don’t need to setup refresh at all. 但是,如果需要在 Power BI 中立即看到更新,则可以使用“立即刷新”来手动刷新数据集。However, if you need to see your updates in Power BI immediately, you can manually refresh the dataset by using Refresh Now.

有关详细信息,请参阅 Power BI 中的 Excel 数据刷新根据 OneDrive 上 Excel 工作簿创建的数据集To learn more, see Excel data in Power BI, or Refresh a dataset created from an Excel workbook on OneDrive.

Excel 工作簿连接到公司中的 SQL 数据库Excel workbook connects to a SQL database in your company

我们假设你在本地计算机上具有一个名为 SalesReport.xlsx 的 Excel 工作簿。Let’s say you have an Excel workbook named SalesReport.xlsx on your local computer. Excel 中的 Power Query 用于连接到公司中服务器上的 SQL 数据库,并查询加载到数据模型中的销售数据。Power Query in Excel was used to connect to a SQL database on a server in your company and query for sales data that is loaded into the data model. 每天早上,你会打开该工作簿并点击“刷新”来更新数据透视表。Each morning, you open the workbook and hit Refresh to update your PivotTables.

现在你要在 Power BI 中浏览销售数据,因此你使用“获取数据”连接到并上载本地驱动器中的 SalesReport.xlsx 工作簿。Now you want to explore your sales data in Power BI, so you use Get Data to connect to and upload the SalesReport.xlsx workbook from your local drive.

在这种情况下,可以手动刷新 SalesReport.xlsx 数据集中的数据或设置刷新计划。In this case, you can manually refresh the data in the SalesReport.xlsx dataset or setup a refresh schedule. 因为数据实际来自公司中的 SQL 数据库,所以你需要下载并安装网关。Because the data really comes from the SQL database in your company, you’ll need to download and install a gateway. 安装并配置了网关之后,你需要进入 SalesReport 数据集的设置并登录数据源;但是,你只需要执行此操作一次。Once you’ve installed and configured the gateway, you’ll need to go into the SalesReport dataset’s settings and sign in to the data source; but you’ll only have to do this once. 随后可以设置刷新计划,以便 Power BI 自动连接到 SQL 数据库并获取更新的数据。You can then setup a refresh schedule so Power BI automatically connects to the SQL database and gets updated data. 报表和仪表板也会自动更新。Your reports and dashboards will also be updated automatically.

备注

此操作仅会更新 Power BI 服务中数据集内的数据。This will only update the data within the dataset in the Power BI service. 本地文件不会作为刷新的一部分进行更新。Your local file will not be updated as part of the refresh.

若要了解详细信息,请参阅 Power BI 中的 Excel 数据Power BI Gateway - Personal本地数据网关刷新从本地驱动器上的 Excel 工作簿创建的数据集To learn more, see Excel data in Power BI, Power BI Gateway - Personal, On-premises data gateway, Refresh a dataset created from an Excel workbook on a local drive.

包含来自 OData 源的数据的 Power BI Desktop 文件Power BI Desktop file with data from an OData feed

在此例中,使用 Power BI Desktop 中的“获取数据”连接到 OData 源并从中导入人口普查数据。In this case, you use Get Data in Power BI Desktop to connect to and import census data from an OData feed. 在 Power BI Desktop 中创建多个报表,随后将文件命名为 WACensus 并将它保存在公司中的共享上。You create several reports in Power BI Desktop, then name the file WACensus and save it on a share in your company. 随后将该文件发布到 Power BI 服务。You then publish the file to the Power BI service.

在这种情况下,可以手动刷新 WACensus 数据集中的数据或设置刷新计划。In this case, you can manually refresh the data in the WACensus dataset or setup a refresh schedule. 因为数据源中的数据来自联机 OData 源,所以无需安装网关,但需要进入 WACensus 数据集的设置并登录 OData 数据源。Because the data in the data source comes from an OData feed online, you do not need to install a gateway, but you will need to go into the WACensus dataset’s settings and sign in to the OData data source. 随后可以设置刷新计划,以便 Power BI 自动连接到 OData 源并获取更新的数据。You can then setup a refresh schedule so Power BI automatically connects to the OData feed and gets updated data. 报表和仪表板也会自动更新。Your reports and dashboards will also be updated automatically.

若要了解详细信息,请参阅从 Power BI Desktop 发布刷新从本地驱动器上的 Power BI Desktop 文件创建的数据集刷新从 OneDrive 上的 Power BI Desktop 文件创建的数据集To learn more, see Publish from Power BI Desktop, Refresh a dataset created from a Power BI Desktop file on a local drive, Refresh a dataset created from a Power BI Desktop file on OneDrive.

来自组织中其他用户的共享内容包Shared content pack from another user in your organization

你已连接到一个组织内容包。You’ve connected to an organizational content pack. 它包含一个仪表板、几个报表和一个数据集。It includes a dashboard, several reports, and a dataset.

在此方案中,你无法为数据集设置刷新。In this scenario, you cannot setup refresh for the dataset. 创建内容包的数据分析师负责确保根据使用的数据源来刷新数据集。The data analyst who created the content pack is responsible for making sure the dataset is refreshed, depending on the data sources used.

如果未更新内容包中的仪表板和报表,则你要与创建内容包的数据分析师进行讨论。If your dashboards and reports from the content pack aren’t updating, you’ll want to talk to the data analyst who created the content pack.

若要了解详细信息,请参阅组织内容包简介使用组织内容包To learn more, see Introduction to organizational content packs, Work with organizational content packs.

来自联机服务提供程序(如 Salesforce)的内容包Content pack from an online service provider like Salesforce

在 Power BI 中,你已使用“获取数据”连接到联机服务提供程序(如 Salesforce)并从中导入数据。In Power BI you used Get Data to connect to and import your data from an online service provider like Salesforce. 好了,现在没有太多工作要做。Well, not much to do here. Salesforce 数据集自动计划为一天刷新一次。Your Salesforce data set is automatically scheduled to refresh once a day.

与大多数联机服务提供程序一样,Salesforce 一天更新数据一次(通常在夜间)。Like most online service providers, Salesforce updates data once a day, usually at night. 可以手动刷新 Salesforce 数据集,或设置刷新计划,但是这不是必需的,因为 Power BI 会自动刷新数据集,报表和仪表板也会进行更新。You can manually refresh your Salesforce dataset, or setup a refresh schedule, but it’s not necessary because Power BI will automatically refresh the dataset and your reports and dashboards will be updated too.

若要了解详细信息,请参阅适用于 Power BI 的 Salesforce 内容包To learn more, see Salesforce content pack for Power BI.

故障排除Troubleshooting

出现问题时,通常是因为 Power BI 无法登录数据源,或数据集连接到本地数据源,而网关处于脱机状态。When things go wrong, it’s usually because Power BI can’t sign into data sources, or the dataset connects to an on-premises data source and 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.

有关故障排除的详细信息,请参阅用于刷新问题故障排除的工具刷新方案故障排除For more information about troubleshooting, see Tools for troubleshooting refresh issues and Troubleshooting refresh scenarios.

后续步骤Next steps

用于解决刷新问题的工具Tools for troubleshooting refresh issues
刷新方案故障排除Troubleshooting refresh scenarios
Power BI Gateway - PersonalPower BI Gateway - Personal
本地数据网关On-premises data gateway

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