教程:在 Power BI Desktop 中调整和合并数据Tutorial: Shape and combine data in Power BI Desktop

借助 Power BI Desktop,可连接到多个不同类型的数据源,然后调整数据以满足你的需求,使你能够创建可与其他人共享的视觉对象报表。With Power BI Desktop, you can connect to many different types of data sources, then shape the data to meet your needs, enabling you to create visual reports that you can share with others. 调整 意味着转换数据 - 如重命名列或表格、将文本更改为数字、删除行、将第一行设为标题等等。Shaping data means transforming the data – such as renaming columns or tables, changing text to numbers, removing rows, setting the first row as headers, and so on. 合并数据意味着连接到两个或多个数据源,根据需要调整它们,然后将其合并到一个有用的查询中。Combining data means connecting to two or more data sources, shaping them as needed, then consolidating them into one useful query.

在本教程中,将了解如何:In this tutorial, you'll learn to:

  • 使用查询编辑器调整数据Shape data using Query Editor
  • 连接到数据源Connect to a data source
  • 连接到其他数据源Connect to another data source
  • 合并这些数据源,以及创建要在报表中使用的数据模型Combine those data sources, and create a data model to use in reports

本教程演示了如何使用 Power BI Desktop 来调整查询,其中突出显示了一些最常见的任务。This tutorial demonstrates how to shape a query using Power BI Desktop, highlighting some of the most common tasks. 有关此处所用查询的更多详细信息,包括如何从头开始创建查询,请参阅 Power BI Desktop 入门The query used here is described in more detail, including how to create the query from scratch, in Getting Started with Power BI Desktop.

有必要知道 Power BI Desktop 中的查询编辑器大量地使用右键单击菜单和功能区。It’s useful to know that the Query Editor in Power BI Desktop makes ample use of right-click menus, as well as the ribbon. 大部分可在转换功能区选择的内容也可通过右键单击项目(如某列)并从所显示的菜单中进行选择。Most of what you can select in the Transform ribbon is also available by right-clicking an item (such as a column) and choosing from the menu that appears.

调整数据Shape data

如果在查询编辑器中调整数据,你将在查询编辑器加载并呈现数据时提供分步说明(查询编辑器将为你执行此操作)以调整数据。When you shape data in the Query Editor, you’re providing step-by-step instructions (that Query Editor carries out for you) to adjust the data as Query Editor loads and presents it. 原始数据源不受影响,将仅调整或 整理 这一特定的数据视图。The original data source is not affected; only this particular view of the data is adjusted, or shaped.

查询编辑器会记录你指定的步骤(如重命名表格、转换数据类型或删除列),且每当此查询连接到数据源时,都会执行这些步骤,因此数据将始终按你指定的方式进行调整。The steps you specify (such as rename a table, transform a data type, or delete columns) are recorded by Query Editor, and each time this query connects to the data source those steps are carried out so that the data is always shaped the way you specify. 每当你使用 Power BI Desktop 的查询编辑器功能,或任何人使用你的共享查询(如在 Power BI 服务上)时,都会出现此过程。This process occurs whenever you use the Query Editor feature of Power BI Desktop, or for anyone who uses your shared query, such as on the Power BI service. 这些步骤在“应用的步骤”下的“查询设置”窗格中按顺序捕获。Those steps are captured, sequentially, in the Query Settings pane, under Applied Steps.

下图显示已调整查询的查询设置窗格,我们将于接下来几个段落中逐一说明每个步骤。The following image shows the Query Settings pane for a query that has been shaped – we’ll go through each of those steps in the next few paragraphs.

借助 Power BI Desktop 入门中的停用数据(通过连接到 Web 数据源找到),开始调整此数据以满足我们的需求。Using the retirement data from Getting Started with Power BI Desktop, which we found by connecting to a Web data source, let’s shape that data to fit our needs.

首先,添加一个自定义列,在所有数据具有同等因素的前提下计算排名,并将其与现有列“排名”进行比较。For starters, let's add a custom column to calculate rank based on all data being equal factors and compare this to the existing column Rank. 以下为“添加列”功能区,其中箭头指向“自定义列”按钮,可通过此按钮添加自定义列。Here's the Add Column ribbon, with an arrow pointing toward the Custom Column button, which lets you add a custom column.

在“自定义列”对话框中,请在“新列名”中输入“新排名”,然后在“自定义列公式”中输入以下内容:In the Custom Column dialog, in New column name, enter New Rank, and in Custom column formula, enter the following:

([Cost of living] + [Weather] + [Health care quality] + [Crime] + [Tax] + [Culture] + [Senior] + [#"Well-being"]) / 8

确保状态消息显示为“未检测到任何语法错误。”Make sure the status message reads 'No syntax errors have been detected.' 然后单击“确定”。and click OK.

为了保持列数据的一致性,请将新列值转换为整数。To keep column data consistent, lets transform the new column values to whole numbers. 只需右键单击列标题,然后选择“更改类型”>“整数”对其加以更改。Just right-click the column header, and select Change Type > Whole Number to change them.

如需选择多列,请先选择一列然后按住 SHIFT,再选择其他相邻列,然后右键单击列标题以更改所有选中的列。If you need 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 键来选择不相邻的列。You can also use the CTRL key to choose non-adjacent columns.

还可以从“转换”功能区转换列数据类型。You can also transform column data types from the Transform ribbon. 转换功能区显示如下,其中箭头指向数据类型按钮,可用于将当前数据类型转换成其他数据类型。Here’s the Transform ribbon, with an arrow pointing toward the Data Type button, which lets you transform the current data type to another.

请注意,在查询设置中,应用的步骤反映了应用到数据的所有调整步骤。Note that in Query Settings, the Applied Steps reflect any shaping steps applied to the data. 如果要删除调整过程中的任意步骤,只需选择步骤左侧的 XIf I want to remove any step from the shaping process, I simply select the X to the left of the step. 在下图中, 应用的步骤 反映了至今为止使用的步骤:连接到网页( );选择表格( 导航 );加载表格时,查询编辑器将基于文本的数字列从 文本 自动更改为 整数更改类型 )。In the following image, Applied Steps reflects the steps so far: connecting to the website (Source); selecting the table (Navigation); and while loading the table, Query Editor automatically changed text-based number columns from Text to Whole Number (Changed Type). 最后两个步骤演示了之前的“已添加自定义”和“已更改类型 1”操作。The last two steps show our previous actions with Added Custom and Changed Type1.

我们需要先执行一些更改以将查询中的数据置于所需位置,才可以使用此查询:Before we can work with this query, we need to make a few changes to get its data where we want it:

  • 通过删除列来调整排名 - 我们已决定结果中的“生活成本”是一个非因素。Adjust the rankings by removing a column - we have decided Cost of living is a non-factor in our results. 删除此列后,我们发现数据保持不变的问题,尽管可以使用 Power BI Desktop 轻松修复此问题,且这样做演示了查询中“应用的步骤”的一个很酷的功能。After removing this column, we find the issue that the data remains unchanged, though it's easy to fix using Power BI Desktop, and doing so demonstrates a cool feature of Applied Steps in Query.
  • 修复一些错误 - 由于我们删除了一个列,因此需要重新调整“新排名”列中的计算。Fix a few errors – since we removed a column, we need to readjust our calculations in the New Rank column. 这涉及公式更改。This involves changing a formula.
  • 对数据进行排序 - 基于“新排名”和“排名”列。Sort the data - based on the New Rank and Rank columns.
  • 替换数据 - 我们将重点介绍如何替换特定值以及插入“应用的步骤”的要求。Replace data - we will highlight how to replace a specific value and the need of inserting an Applied Step.
  • 更改表格名称 - “表格 0”不是有用的描述符,但更改它很简单。Change the table name – that Table 0 is not a useful descriptor, but changing it is simple.

若要删除“生活成本”列,只需选中此列并依次选择功能区中的“开始”选项卡和“删除列”,如下图所示。To remove the Cost of living column, simply select the column and choose the Home tab from the ribbon, then Remove Columns as shown in the following figure.

请注意,新排名值未发生更改;其原因在于步骤的顺序。Notice the New Rank values have not changed; this is due to the ordering of the steps. 由于查询编辑器按顺序记录步骤,但各个步骤相互独立,因此可在序列中上下移动每个所应用步骤Since Query Editor records the steps sequentially, yet independently of each other, you can move each Applied Step up or down in the sequence. 只需右键单击任意步骤,查询编辑器就会提供一个菜单,让你执行下述操作:重命名删除删除****到末尾(删除当前步骤及所有后续步骤)、上移下移Just right-click any step, and Query Editor provides a menu that lets you do the following: Rename, Delete, Delete Until End (remove the current step, and all subsequent steps too), Move Up, or Move Down. 请继续,并将最后一步“已删除列”上移至“已添加自定义”步骤的正上方。Go ahead and move up the last step Removed Columns to just above the Added Custom step.

接下来,选择“已添加自定义”步骤。Next, select the Added Custom step. 请注意,此数据现在显示一个待处理的“错误”。Notice the data now shows Error which we will need to address.

可采用以下几种方法来获取每个错误的详细信息。There are a few ways to get more information about each error. 可选择单元格(无需单击错误一词),或直接单击错误这个词。You can select the cell (without clicking on the word Error), or click the word Error directly. 如果选择单元格而 错误 字词上直接单击,则查询编辑器在窗口底部显示错误信息。If you select the cell without clicking directly on the word Error, Query Editor displays the error information on the bottom of the window.

如果直接单击 错误 这个词,则查询将在 查询设置 中创建 所应用步骤 ,并显示错误的相关信息。If you click the word Error directly, Query creates an Applied Step in the Query Settings pane and displays information about the error. 我们不希望继续,所以选择“取消”。We do not want to go this route, so select Cancel.

若要修复错误,请选择“新排名”列,然后打开“视图”功能区并选择“公式栏”复选框来显示列的数据公式。To fix the errors, select the New Rank column, then display the column's data formula by opening the View ribbon and selecting the Formula Bar checkbox.

现在可以删除“生活成本”参数并减少除数,方法是将公式更改为以下公式:Now you can remove the Cost of living parameter and decrement the divisor, by changing the formula to the following:

Table.AddColumn(#"Removed Columns", "New Rank", each ([Weather] + [Health care quality] + [Crime] + [Tax] + [Culture] + [Senior] + [#"Well-being"]) / 7)

选择公式框左侧的绿色复选标记或按 Enter,数据应替换为修改后的值,且“已添加自定义”步骤现应完成且未出错。Select the green checkmark to the left of the formula box or press Enter, and the data should be replaced by revised values and the Added Custom step should now complete with no errors.

备注

还可以删除错误(使用功能区或右键单击菜单),这将删除具有错误的任意行。You can also Remove Errors (using the ribbon or the right-click menu), which removes any rows that have errors. 这种情况下,它不会删除数据中的所有行,而且我们也不想这样做,我们想要所有数据,并希望将其保留在表格中。In this case it would’ve removed all the rows from our data, and we didn’t want to do that – we like all our data, and want to keep it in the table.

现在需要基于“新排名”列对数据进行排序。Now we need to sort the data based on the New Rank column. 首先选择最后一个应用的步骤“已更改类型 1”以访问最新数据。First select the last applied step, Changed Type1 to get to the most recent data. 然后,选择“新排名”列标题旁边的下拉列表,并选择“升序排序”。Then, select drop-down located next to the New Rank column header and select Sort Ascending.

请注意,数据现在会根据“新排名”进行排序。Notice the data is now sorted according to New Rank. 但是,如果查看“排名”列,将注意到在“新排名”值为一个并列值的情况下,数据未正确排序。However, if you look in the Rank column, you will notice the data is not sorted properly in cases where the New Rank value is a tie. 若要解决此问题,请选择“新排名”列并将“公式栏”中的公式更改为以下公式:To fix this, select the New Rank column and change the formula in the Formula Bar to the following:

= Table.Sort(#"Changed Type1",{{"New Rank", Order.Ascending},{"Rank", Order.Ascending}})

选择公式框左侧的绿色复选标记或按 Enter,行现在应同时根据“新排名”和“排名”进行排序。Select the green checkmark to the left of the formula box or press Enter, and the rows should now be ordered in accordance with both New Rank and Rank.

此外,还可在列表的任何位置选择所应用步骤,然后继续在序列中此点处调整数据。In addition, you can select an Applied Step anywhere in the list, and continue shaping the data at that point in the sequence. 查询编辑器将在当前选定的所应用步骤后直接自动插入一个新步骤。Query Editor will automatically insert a new step directly after the currently selected Applied Step. 我们来试一试。Let's give that a try.

首先,选择“应用的步骤”,然后添加自定义列;这将是“已删除列”步骤。First, select the Applied Step prior to adding the custom column; this would be the Removed Columns step. 我们将在此替换亚利桑那州的“天气”排名值。Here we will replace the value of the Weather ranking in Arizona. 右键单击包含亚利桑那州“天气”排名的相应单元格,然后从显示的菜单中选择“替换值...”。Right-click the appropriate cell that contains Arizona's Weather ranking and select Replace Values... from the menu that appears. 记下当前选择的“应用的步骤”(“已添加自定义”步骤之前的步骤)。Note which Applied Step is currently selected (the step prior to the Added Custom step).

因为我们要插入步骤,所以查询编辑器提醒我们这样做的危险 - 后续步骤可能导致查询中断。Since we're inserting a step, Query Editor warns us about the danger of doing so - subsequent steps could cause the query to break. 我们需要小心谨慎、深思熟虑!We need to be careful, and thoughtful! 由于这是一个教程,而我们要重点介绍查询编辑器的一项炫酷功能以展示如何创建、删除、插入和记录步骤,所以我们将继续操作并选择插入Since this is a tutorial, and we're highlighting a really cool feature of Query Editor to demonstrate how you can create, delete, insert, and reorder steps, we'll push ahead and select Insert.

将值更改为 51,随即会替换表示亚利桑那州的数据。Change the value to 51 and the data for Arizona is replaced. 创建新的所应用步骤时,查询编辑器会根据操作对其命名 - 本例中,命名为替换值When you create a new Applied Step, Query Editor names it based on the action - in this case, Replaced Value. 当查询中具有多个名称相同的步骤时,查询编辑器将对每个后续的所应用步骤添加一个编号(按顺序)以对其进行区分。When you have more than one step with the same name in your query, Query Editor adds a number (in sequence) to each subsequent Applied Step to differentiate between them.

现在选择最后一个“应用的步骤”,“已排序行”,会发现有关亚利桑那州的新排名的数据已发生变化。Now select the last Applied Step, Sorted Rows, and notice the data has changed regarding Arizona's new ranking. 这是因为我们在“已添加自定义”步骤前,在正确的位置插入了“已替换值”步骤。This is because we inserted the Replaced Value step in the right place, before the Added Custom step.

这有点复杂,但它很好地列举了查询编辑器是多么的功能强大、灵活通用。Okay that was a little involved, but it was a good example of how powerful and versatile Query Editor can be.

最后,我们想将此表格的名称更改为描述性内容。Lastly, we want to change the name of that table to something descriptive. 在开始创建报表时,具有描述性的表格名称尤其有用,特别是当连接到多个数据源,且它们均在报表视图的字段窗格中列出时。When we get to creating reports, it’s especially useful to have descriptive table names, especially when we connect to multiple data sources, and they’re all listed in the Fields pane of the Report view.

可轻松更改表格名称:在查询设置属性下,只需键入新的表格名称(如下图所示),然后点击 EnterChanging the table name is easy: in the Query Settings pane, under Properties, simply type in the new name of the table, as shown in the following image, and hit Enter. 让我们将此表命名为 RetirementStatsLet’s call this table RetirementStats.

好了,我们已按所需的范围调整了数据。Okay, we’ve shaped that data to the extent we need to. 接下来,让我们连接到其他数据源,然后合并数据。Next let’s connect to another data source, and combine data.

合并数据Combine data

有关各州的那份数据很有趣,而且适用于生成其他分析工作和查询。That data about various states is interesting, and will be useful for building additional analysis efforts and queries. 但是有一个问题:大多数数据使用两个字母的州名代码缩写,而不是该州的完整名称。But there’s one problem: most data out there uses a two-letter abbreviation for state codes, not the full name of the state. 我们需要某种方式来建立州名及其缩写的关联。We need some way to associate state names with their abbreviations.

我们很幸运:有另一个公共数据源可执行该项工作,但还需要进行相当多的调整,才能连接到我们的退休表。We’re in luck: there’s another public data source that does just that, but it needs a fair amount of shaping before we can connect it to our retirement table. 以下是州名缩写的 Web 资源:Here’s the Web resource for state abbreviations:

http://en.wikipedia.org/wiki/List_of_U.S._state_abbreviations

从查询编辑器的“开始”功能区中,选择“新源”>“Web”,然后键入地址并选择“连接”,随后导航器会显示其在此网页上找到的信息。From the Home ribbon in Query Editor, we select New Source > Web and type the address, select Connect, and the Navigator shows what it found on that Web page.

我们选择“代码和缩写...”,因为它包含所需数据,但它需要大量调整才能将表格中的数据削减到我们想要的数据。We select Codes and abbreviations... because that includes the data we want, but it’s going to take quite a bit of shaping to pare that table’s data down to what we want.

提示

是否有更快或更容易的方法完成以下步骤?Is there a faster or easier way to accomplish the steps below? 是,我们可以创建两个表之间的关系并基于该关系调整数据。Yes, we could create a relationship between the two tables, and shape the data based on that relationship. 以下步骤对了解表的用法仍非常有用,但需知道关系可以帮助你快速使用来自多个表的数据。The following steps are still good to learn for working with tables, just know that relationships can help you quickly use data from multiple tables.

若要调整此数据,我们需要执行以下步骤:To get this data into shape, we take the following steps:

  • 删除顶行 - 它包含网页表格创建方式的结果,不是所需的行。Remove the top row – it's a result of the way that Web page’s table was created, and we don’t need it. 开始功能区中,选择减少行 > 删除行 > 删除前几行From the Home ribbon, select Reduce Rows > Remove Rows > Remove Top Rows.

将显示删除前几行窗口,让你执行要删除几行。The Remove Top Rows window appears, letting you specify how many rows you want to remove.

备注

如果 Power BI 意外导入表标题作为数据表中的行,可以从“主页”选项卡,或者从功能区的“转换”选项卡选择“将第一行用作标题”,以便修复表。If Power BI accidentally imports the table headers as a row in your data table, you can select Use First Row As Headers from the Home tab, or from the Transform tab in the ribbon, to fix your table.

  • 删除底部的 26 行 - 它们全是地区,无需包含在内。Remove the bottom 26 rows – they’re all the territories, which we don’t need to include. 开始功能区中,选择减少行 > 删除行 > 删除后几行From the Home ribbon, select Reduce Rows > Remove Rows > Remove Bottom Rows.

  • 由于 RetirementStats 表没有针对华盛顿特区的信息,我们需要将其从列表中筛选去除。Since the RetirementStats table doesn't have information for Washington DC, we need to filter it from our list. 选择“区域状态”列旁边的下拉箭头,然后清除联邦特区旁边的复选框。Select the drop-down arrow beside the Region Status column, then clear the checkbox beside Federal district.

  • 删除一些不需要的列 - 只需将州映射到其两个字母的官方缩写,因此可删除以下列:Column1、Column3、Column4,然后是 Column6 到 Column11。Remove a few unneeded columns – we only need the mapping of state to its official two-letter abbreviation, so we can remove the following columns: Column1, Column3, Column4, and then Column6 through Column11. 首先选择“Column1”,然后按住 CTRL 键并选择要删除的其他列(可由此选择多个不相邻的列)。First select Column1, then hold down the CTRL key and select the other columns to be removed (this lets you select multiple, non-contiguous columns). 从功能区的“开始”选项卡上,选择删除列 > 删除列From the Home tab on the ribbon, select Remove Columns > Remove Columns.

备注

此时非常适合指出,查询编辑器中已应用步骤的序列很重要,可能会影响数据调整方式。This is a good time to point out that the sequence of applied steps in Query Editor is important, and can affect how the data is shaped. 同时也必须考虑一个步骤对另一个后续步骤可能会有什么影响;如果你从“所应用步骤”中删除一个步骤,则由于查询中步骤序列的影响,后续步骤可能不会按原本所期望的进行操作。It’s also important to consider how one step may impact another subsequent step; if you remove a step from the Applied Steps, subsequent steps may not behave as originally intended, because of the impact of the query’s sequence of steps.

备注

如果将查询编辑器窗口大小重设为宽度缩小,部分功能区项会进行简缩,以充分利用可视空间。When you resize the Query Editor window to make the width smaller, some ribbon items are condensed to make the best use of visible space. 在增加查询编辑器窗口的宽度时,功能区项将展开以充分利用已增加的功能区区域。When you increase the width of the Query Editor window, the ribbon items expand to make the most use of the increased ribbon area.

  • 重命名列,然后重命名表格本身 - 同样的,有几种方式可用于重命名列;首先选择此列,然后选择功能区上转换选项卡中的重命名,或者右键单击并从显示的菜单中选择重命名…Rename the columns, and the table itself – as usual, there are a few ways to rename a column; first select the column, then either select Rename from the Transform tab on the ribbon, or right-click and select Rename… from the menu that appears. 下图具有指向这两个选项的箭头;只需任选其一。The following image has arrows pointing to both options; you only need to choose one.

让我们将其重命名为 州名州代码Let’s rename them to State Name and State Code. 若要重命名表格,只需在查询设置窗格的名称框内键入名称。To rename the table, just type the name into the Name box in the Query Settings pane. 让我们将此表命名为 StateCodesLet’s call this table StateCodes.

我们已按所需方式调整了 StateCodes 表,接下来将这两个表或查询合并成一个;由于当前具有的表格是应用到数据的查询的结果,因此它们通常称为 查询Now that we’ve shaped the StateCodes table the way we want, let’s combine these two tables, or queries, into one; since the tables we now have are a result of the queries we applied to the data, they’re often referred to as queries.

有两种主要方法可合并查询 – 合并追加There are two primary ways of combining queries – merging and appending.

当你有一列或多列要添加到另一个查询时,你可合并这些查询。When you have one or more columns that you’d like to add to another query, you merge the queries. 当你有其他列要添加到现有查询时,你可追加查询。When you have additional rows of data that you’d like to add to an existing query, you append the query.

本例中,我们要合并查询。In this case, we want to merge queries. 若要开始,请从查询编辑器的左窗格中选择想要其他查询合并 的查询,本例中为 RetirementStatsTo get started, from the left pane of Query Editor we select the query into which we want the other query to merge, which in this case is RetirementStats. 然后从功能区的开始选项卡中,选择合并 > 合并查询Then select Combine > Merge Queries from the Home tab on the ribbon.

系统可能会提示你设置隐私级别,以确保对数据进行合并,且不包括或不传输无需传输的数据。You may be prompted to set the privacy levels, to ensure the data is combined without including or transferring data you didn't want transferred.

接下来将显示合并窗口,提示我们选择想要合并到所需表中的表格,然后选择要用于合并的匹配列。Next the Merge window appears, prompting us to select which table we’d like merged into the selected table, and then, the matching columns to use for the merge. RetirementStats 表(查询)中选择州,然后选择 StateCodes 查询(本例中很简单,因为仅有一个其他查询 - 在连接到多个数据源时,存在可从中选择的多个查询)。Select State from the RetirementStats table (query), then select the StateCodes query (easy in this case, since there’s only one other query – when you connect to many data sources, there are many queries to choose from). 在选择正确的匹配列时(RetirementStats 中的StateCodes 中的州名),合并窗口如下所示,且确定按钮已启用。When we select the correct matching columns – State from RetirementStats, and State Name from StateCodes – the Merge window looks like the following, and the OK button is enabled.

在查询的结尾会创建 NewColumn,它是与现有查询合并的表(查询)内容。A NewColumn is created at the end of the query, which is the contents of the table (query) that was merged with the existing query. 来自合并查询的所有列均压缩到 NewColumn 中,但可选择展开数据表并包含所需的任意列。All columns from the merged query are condensed into the NewColumn, but you can select to Expand the table, and include whichever columns you want.

若要展开合并的表格,并选择要包含的列,请选择“展开”图标(展开)。To Expand the merged table, and select which columns to include, select the expand icon (Expand). 展开窗口随即出现。The Expand window appears.

在此示例中,我们只需要州代码列,因此仅选择此列,然后选择确定In this case, we only want the State Code column, so we select only that column and then select OK. 清除“使用原始列名作为前缀”复选框,因此无需或不想要此操作;如果保留选择它,则合并的列将命名为 NewColumn.State Code(原始列名,或者 NewColumn 后接一个点,再接要带入查询的列名)。We clear the checkbox from Use original column name as prefix because we don’t need or want that; if we leave that selected, the merged column would be named NewColumn.State Code (the original column name, or NewColumn, then a dot, then the name of the column being brought into the query).

备注

想尝试了解如何引入此 NewColumn 表吗?Want to play around with how to bring in that NewColumn table? 你可以试验一下,如果不喜欢结果,只需从查询设置窗格中所应用步骤列表删除该步骤,你的查询便会回到应用展开步骤之前的状态。You can experiment a bit, and if you don’t like the results, just delete that step from the Applied Steps list in the Query Settings pane; your query returns to the state prior to applying that Expand step. 这就像是个自由重做的机会,你可以不限次数地任意执行,直到展开过程看起来是你要的方式为止。It’s like a free do-over, which you can do as many times as you like until the expand process looks the way you want it.

我们现在有合并两个数据源的单一查询 (表格),其中每个数据源都已经过调整以符合我们的需求。We now have a single query (table) that combined two data sources, each of which has been shaped to meet our needs. 此查询可以作为许多其他相关数据连线的基础 – 例如任何州的住房成本统计数据、人口统计数据或工作机会。This query can serve as a basis for lots of additional, interesting data connections – such as housing cost statistics, demographics, or job opportunities in any state.

若要应用更改和关闭查询编辑器,请从“主页”功能区选项卡中选择“关闭并应用”。转换后的数据集将在 Power BI Desktop 中显示,可随时用于创建报表。To apply changes and close Query Editor, select Close & Apply from the Home ribbon tab. The transformed dataset appears in Power BI Desktop, ready to be used for creating reports.

后续步骤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: