连接到 Power BI Desktop 中的数据Connect to data in Power BI Desktop

通过 Power BI Desktop,你可以轻松连接到持续扩展的数据世界。With Power BI Desktop you can easily connect to the ever expanding world of data. 如果没有 Power BI Desktop,你可以下载并进行安装。If you don’t have Power BI Desktop, you can download and install it.

Power BI Desktop.中有 各种 可用数据源。There are all sorts of data sources available in Power BI Desktop. 下图显示了如何通过依次选择文件功能区、获取数据>更多来连接到数据。The following image shows how to connect to data, by selecting the File ribbon, then Get Data > More.

在此示例中,我们将连接到 Web 数据源。For this example, we'll connect to a Web data source.

假设你即将退休 - 你希望居住到一个阳光充足、税制合理且具备良好卫生保健的地方。Imagine you’re retiring – you want to live where there’s lots of sunshine, preferable taxes, and good health care. 或者...Or… 也许你是一位数据分析人员,并且你需要该信息来帮助你的客户 - 例如,帮助你的雨衣制造客户将目标市场定位在 经常 下雨的地方。perhaps you’re a data analyst, and you want that information to help your customers – as in, help your raincoat manufacturing client target sales where it rains a lot.

无论如何,你都可以在下列 Web 资源中找到这些主题的相关有趣数据和详细信息:Either way, you find a Web resource that has interesting data about those topics, and more:

http://www.bankrate.com/finance/retirement/best-places-retire-how-state-ranks.aspxhttp://www.bankrate.com/finance/retirement/best-places-retire-how-state-ranks.aspx

选择获取数据> Web,然后键入地址。You select Get Data > Web and type the address.

选择确定后,Power BI Desktop 的查询功能就会开始运行。When you select OK, the Query functionality of Power BI Desktop goes to work. Power BI Desktop 会联系 Web 资源,导航器窗口将返回它在该网页上找到的结果。Power BI Desktop contacts the Web resource, and the Navigator window returns the results of what it found on that Web page. 在本例中,它找到一个表(表格 0)和整份文档。In this case, it found a table (Table 0) and the overall Document. 我们对该表有兴趣,因此我们从列表中选择它。We’re interested in the table, so we select it from the list. 导航器窗口会显示预览。The Navigator window displays a preview.

此时我们可以通过从窗口底部选择编辑,先编辑查询再加载表,或者我们可以直接加载表。At this point we can edit the query before loading the table, by selecting Edit from the bottom of the window, or we can load the table.

如果选择编辑,则会加载该表并启动查询编辑器。If we select Edit, the table is loaded and Query Editor is launched. 会显示查询设置窗格(若未显示,可以从功能区选择视图,然后依次选择显示 > 查询设置来显示查询设置窗格)。The Query Settings pane is displayed (if it’s not, you can select View from the ribbon, then Show > Query Settings to display the Query Settings pane). 以下是其外观。Here’s what that looks like.

所有分数都是文本而非数字,而我们需要使用数字。All those scores are text rather than numbers, and we need them to be numbers. 没问题 – 只需右键单击列标题,然后选择更改类型 > 整数来对其进行更改。No problem – just right-click the column header, and select Change Type > Whole Number to change them. 若要选择多列,请先选择一列然后按住 Shift,再选择其他相邻列,然后右键单击列标题以更改所有选中的列。To choose more than one column, first select a column then hold down SHIFT, select additional adjacent columns, and then right-click a column header to change all selected columns. 使用 Ctrl 来选择不相邻的列。Use CTRL to choose columns that are not adjacent.

查询设置中,所应用步骤会反映任何已做的更改。In Query Settings, the Applied Steps will reflect any changes that were made. 对数据进行其他更改时,查询编辑器将在所应用步骤部分记录更改内容,你可以根据需要进行调整、重新访问、重新排列或删除。As you make additional changes to the data, Query Editor will record those changes in the Applied Steps section, which you can adjust, revisit, rearrange, or delete as necessary.

加载表后,仍可对其进行其他更改,但目前到此为止即可。Additional changes to the table can still be made after it’s loaded, but for now this will do. 完成时,从开始功能区选择关闭并应用,Power BI Desktop 则会应用更改并关闭查询编辑器。When we're done we select Close & Apply from the Home ribbon, and Power BI Desktop applies our changes and closes Query Editor.

加载数据模型后,即可在 Power BI Desktop 的报表视图中通过将字段拖动到画布上开始创建可视化效果。With the data model loaded, in Report view in Power BI Desktop, we can begin creating visualizations by dragging fields onto the canvas.

当然,这只具有单一数据连接的简单模型;大多数 Power BI Desktop 报表会连接到不同的数据源并根据需要调整各种关系以产生丰富的数据模型。Of course, this is a simple model with a single data connection; most Power BI Desktop reports will have connections to different data sources, shaped to meet your needs, with relationships that produce a rich data model.

后续步骤Next steps

Power BI Desktop 可用于执行多种操作。There are all sorts of things you can do with Power BI Desktop. 有关其功能的详细信息,请参阅下列资源:For more information on its capabilities, check out the following resources:

要向我们提供反馈?Want to give us feedback? 很好 - 请使用 Power BI Desktop 中的发送反馈菜单项。Great – use the Send Feedback menu item in Power BI Desktop. 我们期待收到你的留言!We look forward to hearing from you!