在 Power BI Desktop 中使用 Analysis Services 表格数据Using Analysis Services Tabular data in Power BI Desktop

借助 Power BI Desktop,你有两种方法可以连接到 SQL Server Analysis Services 表格模型并从中获取数据:通过使用实时连接浏览或选择项目并将其导入到 Power BI Desktop。With Power BI Desktop, there are two ways you can connect to and get data from your SQL Server Analysis Services Tabular models: Explore by using a live connection or Select items and import into Power BI Desktop.

让我们仔细了解下。Let’s take a closer look.

通过使用实时连接浏览 – 使用实时连接时,表格模型或透视中的项目(如表格、列和度量值)会显示在 Power BI Desktop 字段列表中。Explore by using a live connection – When using a live connection, items in your Tabular model or perspective, like tables, columns, and measures appear in your Power BI Desktop Fields list. 你可以使用 Power BI Desktop 的高级可视化效果和报表工具以全新且高度交互的方式浏览你的表格模型。You can use Power BI Desktop’s advanced visualization and report tools to explore your Tabular model in new, highly interactive ways.

在进行实时连接时,表格模型中的数据不会导入到 Power BI Desktop 中。When connecting live, no data from the Tabular model is imported into Power BI Desktop. 每次与可视化效果进行交互时,Power BI Desktop 都将查询表格模型,并计算你所看到的结果。Each time you interact with a visualization, Power BI Desktop queries the Tabular model and calculates the results you see. 你看到的始终是最新的数据。You’re always looking at the latest data. 请记住,表格模型是高度安全的。Keep in-mind, Tabular models are highly secure. 在 Power BI Desktop 中显示的项目取决于你对连接到的表格模型所具有的权限。Items that appear in Power BI Desktop depend on your permissions for the Tabular model you’re connected to.

当你在 Power BI Desktop 中创建了动态报表后,可以将它们发布到 Power BI 站点进行共享。When you’ve created dynamic reports in Power BI Desktop, you can share them by publishing to your Power BI site. 当使用与表格模型的实时连接将 Power BI Desktop 文件发布到 Power BI 站点时,管理员必须安装并配置本地数据网关。When you publish a Power BI Desktop file with a live connection to a Tabular model to your Power BI site, an on-premises data gateway must be installed and configured by an administrator. 若要了解详细信息,请参阅本地数据网关To learn more, see On-premises data gateway.

选择项目并导入到 Power BI Desktop 中 – 使用此选项进行连接时,你可以在表格模型或透视中选择项目(如表、列和度量值),并将其加载到 Power BI Desktop 模型中。Select items and import into Power BI Desktop – When you connect with this option, you can select items like tables, columns, and measures in your Tabular model or perspective and load them into a Power BI Desktop model. 你可以使用 Power BI Desktop 的高级查询编辑器进一步调整你所需查询的内容。You can use Power BI Desktop’s advanced Query Editor to further shape what you want. 你可以使用 Power BI Desktop 的建模功能进一步对数据进行建模。You can use Power BI Desktop’s modeling features to further model the data. Power BI Desktop 和表格模型之间不会保持实时连接。No live connection between Power BI Desktop and the Tabular model is maintained. 接着,你可以脱机浏览你的 Power BI Desktop 模型或将其发布到 Power BI 站点。You can then explore your Power BI Desktop model offline or publish to your Power BI site.

连接到表格模型To connect to a Tabular model

  1. 在 Power BI Desktop 中,在开始选项卡上,单击获取数据In Power BI Desktop, on the Home tab, click Get Data.

  2. 单击 SQL Server Analysis Services 数据库,然后单击连接Click SQL Server Analysis Services Database, then click Connect.

  3. 输入服务器名称并选择连接模式。Enter the Server name and select a connection mode.

  4. 此步骤取决于你所选的连接模式:This step depends on the connection mode you selected:
  • 如果你正在进行实时连接中,请在导航器中选择“表格”模型或透视。If you’re connecting live, in Navigator, select a Tabular model or perspective.

  • 如果你选择了选择项目并获取数据,请在导航器中选择“表格”模型或透视。If you chose Select items and get data, in Navigator, select a Tabular model or perspective. 你可以进一步仅选择特定的表或列进行加载。You can further select only particular tables or columns to load. 若要在加载前对数据进行调整,请单击“编辑”以打开查询编辑器。To shape your data before loading, click Edit to open Query Editor. 准备就绪时,单击“加载”将数据导入到 Power BI Desktop 中。When you’re ready, click Load to import the data into Power BI Desktop.

常见问题Frequently Asked Questions

问:我是否需要一个本地数据网关?Question: Do I need an on-premises data gateway?

答:这个需要视情况而定。Answer: It depends. 如果你使用 Power BI Desktop 实时连接到表格模型,但不打算发布到 Power BI 站点,则不需要网关。If you use Power BI Desktop to connect live to a Tabular model, but have no intention on publishing to your Power BI site, you do not need a gateway. 另一方面,如果你确实想将其发布到 Power BI 站点,则数据网关是必需的,以确保 Power BI 服务与你的本地 Analysis Services 服务器之间的通信安全。On the other hand, if you do intend on publishing to your Power BI site, a data gateway is necessary to ensure secure communication between the Power BI service and your on-premises Analysis Services server. 请务必在安装数据网关之前与 Analysis Services 服务器管理员联系。Be sure to talk to your Analysis Services server administrator before installing a data gateway.

如果你选择了选择项目并获取数据,则你会将表格模型数据直接导入到 Power BI Desktop 文件中,因此不需要网关。If you choose select items and get data, you’re importing Tabular model data right into your Power BI Desktop file, so no gateway is necessary.

问:从 Power BI 服务实时连接到表格模型与从 Power BI Desktop 中实时连接到表格模型之间有什么区别?Question: What’s the difference between connecting live to a Tabular model from the Power BI service versus connecting live from Power BI Desktop?

答:当从 Power BI 服务中的站点将表格模型实时连接到组织中的本地 Analysis Services 数据库时,需要本地数据网关来确保它们之间的通信安全。Answer: When connecting live to a Tabular model from your site in the Power BI service to an Analysis Services database on-premises in your organization, an on-premises data gateway is required to secure communications between them. 当从 Power BI Desktop 实时连接到表格模型时,因为 Power BI Desktop 和要连接到的 Analysis Services 服务器都是在组织中本地运行的,因此不需要网关。When connecting live to a Tabular model from Power BI Desktop, a gateway is not required because both Power BI Desktop and the Analysis Services server you’re connecting to are both running on-premises in your organization. 但是,如果将 Power BI Desktop 文件发布到 Power BI 站点,则需要网关。However, if you publish your Power BI Desktop file to your Power BI site, a gateway is required.

问:如果我创建了实时连接,我能否连接到同一个 Power BI Desktop 文件中的其他数据源?Question: If I created a live connection, can I connect to another data source in the same Power BI Desktop file?

答:不能。Answer: No. 你不能在同一文件中浏览实时数据并连接到其他类型的数据源。You cannot explore live data and connect to another type of data source in the same file. 如果你已导入数据或连接到 Power BI Desktop 文件中的另一个数据源,你则需要新建一个文件来实时浏览。If you’ve already imported data or connected to a different data source in a Power BI Desktop file, you’ll need to create a new file to explore live.

问:如果我创建了实时连接,我可以在 Power BI Desktop 中编辑模型或进行查询吗?Question: If I created a live connection, can I edit the model or query in Power BI Desktop?

答案:可以在 Power BI Desktop 中创建报表级别度量值,但当浏览实时数据时会禁用所有其他查询和建模功能。Answer: You can create report level measures in the Power BI Desktop, but all other query and modelling features are disabled when exploring live data.

问:如果我创建了实时连接,它是安全的吗?Question: If I created a live connection, is it secure?

答:是的。Answer: Yes. 你当前的 Windows 凭据用于连接到 Analysis Services 服务器。Your current Windows credentials are used to connect to the Analysis Services server. 在实时浏览时,你不能在 Power BI 服务或 Power BI Desktop 中使用基本或存储的凭据。You cannot use Basic or stored credentials in either the Power BI service or Power BI Desktop when exploring live.

问:在导航器中,我看到模型和透视。Question: In Navigator, I see a model and a perspective. 有什么区别?What’s the difference?

答:透视是表格模型的特定视图。Answer: A perspective is a particular view of a Tabular model. 它可能仅包含特定的表、列或度量值,具体取决于独特的数据分析需求。It might include only particular tables, columns, or measures depending on a unique data analysis need. 表格模型始终包含至少一个透视,其中能包含模型中的所有内容。A Tabular model always contains at least one perspective, which could include everything in the model. 如果你不确定应选择哪个,请与你的管理员联系。If you’re unsure which you should select, check with your administrator.

初始连接后更改服务器名称To change the server name after initial connection

使用实时浏览连接创建 Power BI Desktop 文件后,可能会出现你想要将连接切换到其他服务器的情况。Once you create a Power BI Desktop file with an explore live connection, there might be some cases where you want to switch the connection to a different server. 例如,如果当你在连接到开发服务器时创建了 Power BI Desktop 文件,在发布到 Power BI 服务前,你想要将连接切换至生产服务器。For example, if you created your Power BI Desktop file when connecting to a development server, and before publishing to the Power BI service, you want to switch the connection to production server.

  1. 从功能区中选择编辑查询Select Edit Queries from the Ribbon.

  2. 输入新的服务器名称。Enter the new server name.